Ejemplo n.º 1
0
        public static DictionaryField DecodingDictionary(Stream stream)
        {
            var begin = stream.ReadByte();

            if (begin != _startDictionary)
            {
                throw new Exception("dictionary开始字节错误");
            }
            var offsetStart = stream.Position - 1;
            var result      = DictionaryField.Create();

            while (true)
            {
                var t = stream.ReadByte();
                if (t == _end)
                {
                    result.OffsetStart = offsetStart;
                    result.OffsetEnd   = stream.Position - 1;
                    result.ComputeSha1(stream);
                    return(result);
                }
                else
                {
                    stream.Position -= 1;
                }
                var key = Decode(stream);
                if (key.Type != BType.String)
                {
                    throw new Exception("dictionary的键类型错误");
                }
                var val = Decode(stream);
                result.Value.Add((key as StringField).Value, val);
            }
        }
        /// <summary>
        /// Returns true if EntityViewModel instances are equal
        /// </summary>
        /// <param name="other">Instance of EntityViewModel to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(EntityViewModel other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Id == other.Id ||
                     Id != null &&
                     Id.Equals(other.Id)
                     ) &&
                 (
                     StringField == other.StringField ||
                     StringField != null &&
                     StringField.Equals(other.StringField)
                 ) &&
                 (
                     RelationIdField == other.RelationIdField ||
                     RelationIdField != null &&
                     RelationIdField.Equals(other.RelationIdField)
                 ) &&
                 (
                     DictionaryField == other.DictionaryField ||
                     DictionaryField != null &&
                     DictionaryField.Equals(other.DictionaryField)
                 ) &&
                 (
                     IntegerField == other.IntegerField ||
                     IntegerField != null &&
                     IntegerField.Equals(other.IntegerField)
                 ) &&
                 (
                     DoubleField == other.DoubleField ||
                     DoubleField != null &&
                     DoubleField.Equals(other.DoubleField)
                 ) &&
                 (
                     DateField == other.DateField ||
                     DateField != null &&
                     DateField.Equals(other.DateField)
                 ) &&
                 (
                     ExampleType == other.ExampleType ||
                     ExampleType != null &&
                     ExampleType.Equals(other.ExampleType)
                 ) &&
                 (
                     ExampleStatus == other.ExampleStatus ||
                     ExampleStatus != null &&
                     ExampleStatus.Equals(other.ExampleStatus)
                 ));
        }
Ejemplo n.º 3
0
        public void EqualsFieldsTest()
        {
            var val1 = new DictionaryField()
            {
                Id = Guid.NewGuid(), Value = "NOME DA RUA", Type = "TYPE TESTE"
            };
            var val2 = new DictionaryField()
            {
                Id = Guid.NewGuid(), Value = "NOME DA RUA", Type = "TYPE TESTE"
            };

            Assert.Equal(val1, val2);
        }
Ejemplo n.º 4
0
        public void EqualsIdTest()
        {
            var id   = Guid.NewGuid();
            var val1 = new DictionaryField()
            {
                Id = id
            };
            var val2 = new DictionaryField()
            {
                Id = id
            };

            Assert.Equal(val1, val2);
        }
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Id != null)
         {
             hashCode = hashCode * 59 + Id.GetHashCode();
         }
         if (StringField != null)
         {
             hashCode = hashCode * 59 + StringField.GetHashCode();
         }
         if (RelationIdField != null)
         {
             hashCode = hashCode * 59 + RelationIdField.GetHashCode();
         }
         if (DictionaryField != null)
         {
             hashCode = hashCode * 59 + DictionaryField.GetHashCode();
         }
         if (IntegerField != null)
         {
             hashCode = hashCode * 59 + IntegerField.GetHashCode();
         }
         if (DoubleField != null)
         {
             hashCode = hashCode * 59 + DoubleField.GetHashCode();
         }
         if (DateField != null)
         {
             hashCode = hashCode * 59 + DateField.GetHashCode();
         }
         if (ExampleType != null)
         {
             hashCode = hashCode * 59 + ExampleType.GetHashCode();
         }
         if (ExampleStatus != null)
         {
             hashCode = hashCode * 59 + ExampleStatus.GetHashCode();
         }
         return(hashCode);
     }
 }
Ejemplo n.º 6
0
 public FileInfo(DictionaryField m)
 {
     this._m = m;
 }
Ejemplo n.º 7
0
 public Info(DictionaryField dictionaryField)
 {
     _dictionaryField = dictionaryField;
 }
        public override void Create(VisualElement root)
        {
            var asset             = ScriptableObject.CreateInstance <SampleAsset>();
            var obj               = new SerializedObject(asset);
            var typedPrimitives   = new Dictionary <string, int>();
            var typedClasses      = new Dictionary <string, SampleItemBool>();
            var typedReferences   = new Dictionary <string, ISampleItem>();
            var genericPrimitives = new Dictionary <string, int>();
            var genericClasses    = new Dictionary <string, SampleItemBool>();
            var genericReferences = new Dictionary <string, ISampleItem>();

            var proxies = new List <ProxySelect>
            {
                new ProxySelect("Typed Primitive", new DictionaryProxy <int>(typedPrimitives, CreateInt), null, false, typedPrimitives),
                new ProxySelect("Typed Class", new DictionaryProxy <SampleItemBool>(typedClasses, CreateSampleItemBool), typeof(SampleItemBool), false, typedClasses),
                new ProxySelect("Typed Reference", new DictionaryProxy <ISampleItem>(typedReferences, CreateSampleItem), typeof(ISampleItem), true, typedReferences),
                new ProxySelect("Generic Primitive", new DictionaryProxy(genericPrimitives, CreateInt), typeof(int), false, genericPrimitives),
                new ProxySelect("Generic Class", new DictionaryProxy(genericClasses, CreateSampleItemBool), typeof(SampleItemBool), false, genericClasses),
                new ProxySelect("Generic Reference", new DictionaryProxy(genericReferences, CreateSampleItem), typeof(ISampleItem), true, genericReferences),
                new ProxySelect("Property Primitive", CreatePropertyProxy(obj, nameof(SampleAsset.Primitives)), null, false, asset.Primitives),
                new ProxySelect("Property Class", CreatePropertyProxy(obj, nameof(SampleAsset.Classes)), null, false, asset.Classes),
                new ProxySelect("Property Reference", CreatePropertyProxy(obj, nameof(SampleAsset.References)), typeof(ISampleItem), true, asset.References),
                new ProxySelect("None", null, null, false, null)
            };

            var startingProxy = 0;
            var dictionary    = new DictionaryField();

            dictionary.Label = "Sample Dictionary";
            dictionary.SetProxy(proxies[startingProxy].Proxy, proxies[startingProxy].ItemType, proxies[startingProxy].AllowDerived);
            root.Add(dictionary);

            var proxyPopup = new UnityEditor.UIElements.PopupField <ProxySelect>("Item Type", proxies, startingProxy, proxy => proxy.Name, proxy => proxy.Name);

            proxyPopup.RegisterValueChangedCallback(e => dictionary.SetProxy(e.newValue.Proxy, e.newValue.ItemType, e.newValue.AllowDerived));
            root.Add(proxyPopup);

            var allowAddToggle = new Toggle("Allow Add");

            allowAddToggle.value = dictionary.AllowAdd;
            allowAddToggle.RegisterValueChangedCallback(e => dictionary.AllowAdd = e.newValue);
            root.Add(allowAddToggle);

            var allowRemoveToggle = new Toggle("Allow Remove");

            allowRemoveToggle.value = dictionary.AllowRemove;
            allowRemoveToggle.RegisterValueChangedCallback(e => dictionary.AllowRemove = e.newValue);
            root.Add(allowRemoveToggle);

            var allowReorderToggle = new Toggle("Allow Reorder");

            allowReorderToggle.tooltip = "For properties only - regular dictionaries cannot be reorderable";
            allowReorderToggle.value   = dictionary.AllowReorder;
            allowReorderToggle.RegisterValueChangedCallback(e => dictionary.AllowReorder = e.newValue);
            root.Add(allowReorderToggle);

            var emptyLabelText = new TextField("Empty Label");

            emptyLabelText.value = dictionary.EmptyLabel;
            emptyLabelText.RegisterValueChangedCallback(e => dictionary.EmptyLabel = e.newValue);
            root.Add(emptyLabelText);

            var emptyTooltipText = new TextField("Empty Tooltip");

            emptyTooltipText.value = dictionary.EmptyTooltip;
            emptyTooltipText.RegisterValueChangedCallback(e => dictionary.EmptyTooltip = e.newValue);
            root.Add(emptyTooltipText);

            var addTooltipText = new TextField("Add Tooltip");

            addTooltipText.value = dictionary.AddTooltip;
            addTooltipText.RegisterValueChangedCallback(e => dictionary.AddTooltip = e.newValue);
            root.Add(addTooltipText);

            var addPlaceholderText = new TextField("Add Placeholder");

            addPlaceholderText.value = dictionary.AddPlaceholder;
            addPlaceholderText.RegisterValueChangedCallback(e => dictionary.AddPlaceholder = e.newValue);
            root.Add(addPlaceholderText);

            var removeTooltipText = new TextField("Remove Tooltip");

            removeTooltipText.value = dictionary.RemoveTooltip;
            removeTooltipText.RegisterValueChangedCallback(e => dictionary.RemoveTooltip = e.newValue);
            root.Add(removeTooltipText);

            var reorderTooltipText = new TextField("Reorder Tooltip");

            reorderTooltipText.value = dictionary.ReorderTooltip;
            reorderTooltipText.RegisterValueChangedCallback(e => dictionary.ReorderTooltip = e.newValue);
            root.Add(reorderTooltipText);

            var printButton = new Button(() => Print(proxies[proxyPopup.index].Dictionary));

            printButton.text = "Log Dictionary Contents";
            root.Add(printButton);
        }
Ejemplo n.º 9
0
 public TrackerResponse(DictionaryField dictionaryField, string httpurl)
 {
     _dictionaryField = dictionaryField;
     _ipEndPoint      = GetIpEndpoint(httpurl);
 }
Ejemplo n.º 10
0
        public void EqualsInstanceTest()
        {
            var val1 = new DictionaryField();

            Assert.Equal(val1, val1);
        }
Ejemplo n.º 11
0
        public void EmpityFiedTest()
        {
            var validators = new DictionaryField().Validate();

            Assert.True(validators.Count(c => c.MessageType.Equals(nameof(FieldValueException))) == 6);
        }