Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#WCF-发送自定义BindableDictionary<;字符串,自定义对象>;()在电线上 编辑 好的,我知道了,它是不可序列化的……那么,我该如何序列化它呢 脚本 我有一本定制的BindableDictionary 我用网格绑定的 用于_Wcf_Callback - Fatal编程技术网

C#WCF-发送自定义BindableDictionary<;字符串,自定义对象>;()在电线上 编辑 好的,我知道了,它是不可序列化的……那么,我该如何序列化它呢 脚本 我有一本定制的BindableDictionary 我用网格绑定的 用于

C#WCF-发送自定义BindableDictionary<;字符串,自定义对象>;()在电线上 编辑 好的,我知道了,它是不可序列化的……那么,我该如何序列化它呢 脚本 我有一本定制的BindableDictionary 我用网格绑定的 用于,wcf,callback,Wcf,Callback,C#WCF-发送自定义BindableDictionary<;字符串,自定义对象>;()在电线上 编辑 好的,我知道了,它是不可序列化的……那么,我该如何序列化它呢 脚本 我有一本定制的BindableDictionary 我用网格绑定的 用于自动更新的控件 当底层 数据源更改 我现在想扩展我的应用程序 要使用WCF,请在 服务器端已完成更新 带新标签的BindableDictionary 值,它可以传递此字典 给客户,而客户又可以 在客户端上执行更新 GUI 问题 我如何发送此自

C#WCF-发送自定义BindableDictionary<;字符串,自定义对象>;()在电线上 编辑
  • 好的,我知道了,它是不可序列化的……那么,我该如何序列化它呢
脚本
  • 我有一本定制的BindableDictionary 我用网格绑定的 用于自动更新的控件 当底层 数据源更改
  • 我现在想扩展我的应用程序 要使用WCF,请在 服务器端已完成更新 带新标签的BindableDictionary 值,它可以传递此字典 给客户,而客户又可以 在客户端上执行更新 GUI
  • 问题
    • 我如何发送此自定义文件 在线上查字典
    • 实现这一点的最佳方式是什么
    • 我询问实现方法的原因是,我所看到的用于将数据“推送”到客户机的双工、回调或观察者模式的每个示例,都只使用传递字符串的示例,而且非常简单-每当我更新示例以使用自定义BindableDictionary时,我都无法使其工作
    • 我错过什么了吗
    活页词典
    公共类BindableDictionary:IDictionary,IBindingList
    {
    私有字典源=新字典();
    void IBindingList.AddIndex(PropertyDescriptor属性){}
    对象IBindingList.AddNew(){抛出新的NotImplementedException();}
    bool-IBindingList.AllowEdit{get{return false;}}
    bool-IBindingList.AllowNew{get{return false;}}
    bool IBindingList.AllowRemove{get{return false;}}
    void IBindingList.ApplySort(PropertyDescriptor属性,ListSortDirection方向){}
    int-IBindingList.Find(PropertyDescriptor属性,对象键){抛出新的NotImplementedException();}
    bool-IBindingList.IsSorted{get{return false;}}
    void IBindingList.RemoveIndex(PropertyDescriptor属性){}
    void IBindingList.RemoveSort(){}
    ListSortDirection IBindingList.SortDirection{get{return ListSortDirection.Ascending;}
    PropertyDescriptor IBindingList.SortProperty{get{return null;}}
    bool-IBindingList.SupportsChangeNotification{get{return true;}}
    bool-IBindingList.supportsserching{get{return false;}}
    bool-IBindingList.SupportsSorting{get{return false;}}
    int System.Collections.IList.Add(对象值){抛出新的NotImplementedException();}
    void System.Collections.IList.Clear(){Clear();}
    bool System.Collections.IList.Contains(对象值){if(值为TKey){return source.ContainsKey((TKey)值);}else if(值为TValue){return source.ContainsValue((TValue)值);}return false;}
    int System.Collections.IList.IndexOf(对象值){return-1;}
    void System.Collections.IList.Insert(int索引,对象值){throw new NotImplementedException();}
    bool System.Collections.IList.IsFixedSize{get{return false;}}
    bool System.Collections.IList.IsReadOnly{get{return true;}}
    void System.Collections.IList.Remove(对象值){if(值为TKey){Remove((TKey)值);}
    void System.Collections.IList.RemoveAt(int index){throw new NotImplementedException();}
    对象System.Collections.IList.this[int index]{get{throw new NotImplementedException();}set{throw new NotImplementedException();}}
    私有ListChangedEventHandler listChanged;
    事件ListChangedEventHandler IBindingList.ListChanged
    {
    添加{listChanged+=value;}
    删除{listChanged-=value;}
    }
    受保护的虚拟void OnListChanged(ListChangedEventArgs e)
    {
    var-evt=listChanged;
    如果(evt!=null)evt(this,e);
    }
    公共无效添加(TKey键,TValue值)
    {
    source.Add(键、值);
    OnListChanged(新ListChangedEventArgs(ListChangedType.Reset,-1));
    }
    公用门移除(TKey)
    {
    如果(源。删除(键))
    {
    OnListChanged(新ListChangedEventArgs(ListChangedType.Reset,-1));
    返回true;
    }
    返回false;
    }
    公共TValue此[TKey]
    {
    得到
    {
    返回源[键];
    }
    设置
    {
    源[键]=值;
    OnListChanged(新ListChangedEventArgs(ListChangedType.Reset,-1));
    }
    }
    void ICollection.Add(KeyValuePair项)
    {
    ((ICollection)来源)。添加(项);
    OnListChanged(新ListChangedEventArgs(ListChangedType.Reset,-1));
    }
    布尔ICollection.Remove(KeyValuePair项)
    {
    如果(((ICollection)源)。删除(项))
    {
    OnListChanged(新ListChangedEventArgs(ListChangedType.Reset,-1));
    返回true;
    }
    返回false;
    }
    public bool ContainsKey(TKey){return source.ContainsKey(key);}
    公共ICollection键{get{return source.Keys;}}
    public bool TryGetValue(TKey-key,out-TValue值){return source.TryGetValue(key,out-value);}
    公共ICollection值{get{return source.Values;}}
    public void Clear(){source.Clear();}
    bool ICollection.Contains(KeyValuePair项){return((ICollection)source.Contains(项);}
    void ICollection.CopyTo(KeyValuePair[]数组,int-arrayIndex){((ICollection)源).CopyTo(数组,arrayIndex);}
    公共整数计数{get{return source.Count;}}
    bool ICollection.IsReadOnly{get{return((ICollection)source).IsReadOnly;}
    公共IEnumerator GetEnumerator(){返回源。GetEnumerator();}
    System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator(){return GetEnumerator();}
    
        public class BindableDictionary<TKey, TValue> : IDictionary<TKey, TValue>, IBindingList
        {
            private Dictionary<TKey, TValue> source = new Dictionary<TKey, TValue>();
    
            void IBindingList.AddIndex(PropertyDescriptor property) { }
            object IBindingList.AddNew() { throw new NotImplementedException(); }
            bool IBindingList.AllowEdit { get { return false; } }
            bool IBindingList.AllowNew { get { return false; } }
            bool IBindingList.AllowRemove { get { return false; } }
            void IBindingList.ApplySort(PropertyDescriptor property, ListSortDirection direction) { }
            int IBindingList.Find(PropertyDescriptor property, object key) { throw new NotImplementedException(); }
            bool IBindingList.IsSorted { get { return false; } }
            void IBindingList.RemoveIndex(PropertyDescriptor property) { }
            void IBindingList.RemoveSort() { }
            ListSortDirection IBindingList.SortDirection { get { return ListSortDirection.Ascending; } }
            PropertyDescriptor IBindingList.SortProperty { get { return null; } }
            bool IBindingList.SupportsChangeNotification { get { return true; } }
            bool IBindingList.SupportsSearching { get { return false; } }
            bool IBindingList.SupportsSorting { get { return false; } }
            int System.Collections.IList.Add(object value) { throw new NotImplementedException(); }
            void System.Collections.IList.Clear() { Clear(); }
            bool System.Collections.IList.Contains(object value) { if (value is TKey) { return source.ContainsKey((TKey)value); } else if (value is TValue) { return source.ContainsValue((TValue)value); } return false; }
            int System.Collections.IList.IndexOf(object value) { return -1; }
            void System.Collections.IList.Insert(int index, object value) { throw new NotImplementedException(); }
            bool System.Collections.IList.IsFixedSize { get { return false; } }
            bool System.Collections.IList.IsReadOnly { get { return true; } }
            void System.Collections.IList.Remove(object value) { if (value is TKey) { Remove((TKey)value); } }
            void System.Collections.IList.RemoveAt(int index) { throw new NotImplementedException(); }
            object System.Collections.IList.this[int index] { get { throw new NotImplementedException(); } set { throw new NotImplementedException(); } }
    
            private ListChangedEventHandler listChanged;
    
            event ListChangedEventHandler IBindingList.ListChanged
            {
                add { listChanged += value; }
                remove { listChanged -= value; }
            }
    
            protected virtual void OnListChanged(ListChangedEventArgs e)
            {
                var evt = listChanged;
    
                if (evt != null) evt(this, e);
            }
    
            public void Add(TKey key, TValue value)
            {
                source.Add(key, value);
    
                OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1));
            }
    
            public bool Remove(TKey key)
            {
                if (source.Remove(key))
                {
                    OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1));
    
                    return true;
                }
    
                return false;
            }
    
            public TValue this[TKey key]
            {
                get
                {
                    return source[key];
                }
                set
                {
                    source[key] = value;
    
                    OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1));
                }
            }
    
            void ICollection<KeyValuePair<TKey, TValue>>.Add(KeyValuePair<TKey, TValue> item)
            {
                ((ICollection<KeyValuePair<TKey, TValue>>)source).Add(item);
    
                OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1));
            }
    
            bool ICollection<KeyValuePair<TKey, TValue>>.Remove(KeyValuePair<TKey, TValue> item)
            {
                if (((ICollection<KeyValuePair<TKey, TValue>>)source).Remove(item))
                {
                    OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1));
    
                    return true;
                }
    
                return false;
            }
    
            public bool ContainsKey(TKey key) { return source.ContainsKey(key); }
            public ICollection<TKey> Keys { get { return source.Keys; } }
            public bool TryGetValue(TKey key, out TValue value) { return source.TryGetValue(key, out value); }
            public ICollection<TValue> Values { get { return source.Values; } }
            public void Clear() { source.Clear(); }
            bool ICollection<KeyValuePair<TKey, TValue>>.Contains(KeyValuePair<TKey, TValue> item) { return ((ICollection<KeyValuePair<TKey, TValue>>)source).Contains(item); }
            void ICollection<KeyValuePair<TKey, TValue>>.CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex) { ((ICollection<KeyValuePair<TKey, TValue>>)source).CopyTo(array, arrayIndex); }
            public int Count { get { return source.Count; } }
            bool ICollection<KeyValuePair<TKey, TValue>>.IsReadOnly { get { return ((ICollection<KeyValuePair<TKey, TValue>>)source).IsReadOnly; } }
            public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator() { return source.GetEnumerator(); }
            System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return GetEnumerator(); }
            bool ICollection.IsSynchronized { get { return false; } }
            object ICollection.SyncRoot { get { return null; } }
            void ICollection.CopyTo(Array array, int arrayIndex) { ((ICollection)source).CopyTo(array, arrayIndex); }
        }
    
    [DataContract]
    public class MyDTOType
    {
       [DataMember]   
       public (keytype) Key { get; set; }
       [DataMember]   
       public (valuetype) Value { get; set; }
    }
    
    [DataContract]
    public class MyDTOList
    {
       [DataMember]   
       public List<MyDTOType> ListOfKeyValues { get; set; }
    }
    
    [ServiceContract]
    interface IMyService
    {
        [OperationContract]
        public MyDTOList GetAllValues(int someCriteria);
    }