Example #1
0
 public void CreateMap()
 {
     var document = new HtmlDocument();
     a = new HtmlElement(document, "a");
     a.SetAttribute("data-test1", "test");
     a.SetAttribute("data-b", "b");
     stringMap = new StringMap("data-", a);
 }
 public GameObject GetTarget(StringMap actorMap)
 {
     if (actorMap != null) {
         if (actorMap.ContainsKey(Name)) {
             return GameObject.Find(actorMap.Get(Name).Value);
         }
     }
     return GameObject.Find(Name);
 }
Example #3
0
        public void CaseSensitive_dfltCtor()
        {
            var m = new StringMap();
              m["a"] = "Albert";
              m["A"] = "Albert Capital";

              Assert.AreEqual(2, m.Count);
              Assert.AreEqual("Albert", m["a"]);
              Assert.AreEqual("Albert Capital", m["A"]);
        }
Example #4
0
        public void CaseInsensitive()
        {
            var m = new StringMap(false);
              m["a"] = "Albert";
              m["A"] = "Albert Capital";

              Assert.AreEqual(1, m.Count);
              Assert.AreEqual("Albert Capital", m["a"]);
              Assert.AreEqual("Albert Capital", m["A"]);
        }
Example #5
0
        public void KeyExistence()
        {
            var m = new StringMap();
              m["a"] = "Albert";
              m["b"] = "Benedict";

              Assert.AreEqual(2, m.Count);
              Assert.AreEqual("Albert", m["a"]);
              Assert.AreEqual("Benedict", m["b"]);
              Assert.IsNull(  m["c"] );
              Assert.IsTrue( m.ContainsKey("a"));
              Assert.IsFalse( m.ContainsKey("c"));
        }
Example #6
0
    public void Load(string tag, string value)
    {
		// first look up to see if we need to replace
		foreach( StringMap map in stringmap )
		{
			if ( map.key == tag )
			{
				map.value = value;				
				return;
			}
		}
		// not found, just add a new one
        StringMap newmap = new StringMap(tag, value);
        stringmap.Add(newmap);
    }
Example #7
0
        public void StringMap()
        {
            using(var ms = new MemoryStream())
                    {
                        var r = SlimFormat.Instance.MakeReadingStreamer();
                        var w = SlimFormat.Instance.MakeWritingStreamer();

                        r.BindStream(ms);
                        w.BindStream(ms);

                        var mapS = new StringMap(true)
                        {
                           {"a", "Alex"},
                           {"b","Boris"}
                        };

                        var mapI = new StringMap(false)
                        {
                           {"a", "Alex"},
                           {"b","Boris"},
                           {"c","Chuck"}
                        };

                        w.Write(mapS);
                        w.Write(mapI);

                        ms.Seek(0, SeekOrigin.Begin);

                        var mapS2 = r.ReadStringMap();
                        Assert.IsTrue(mapS2.CaseSensitive);
                        Assert.AreEqual(2, mapS2.Count);
                        Assert.AreEqual("Alex", mapS2["a"]);
                        Assert.AreEqual("Boris", mapS2["b"]);

                        var mapI2 = r.ReadStringMap();
                        Assert.IsFalse(mapI2.CaseSensitive);
                        Assert.AreEqual(3, mapI2.Count);
                        Assert.AreEqual("Alex", mapI2["a"]);
                        Assert.AreEqual("Boris", mapI2["b"]);
                        Assert.AreEqual("Chuck", mapI2["c"]);
                    }
        }
Example #8
0
        public void StringMap_Pretty()
        {
            var map = new StringMap
            {
              {"p1", "v1"},
              {"p2", "v2"},
              {"Age", "149"}
            };

            var json = map.ToJSON(JSONWritingOptions.PrettyPrint);
            Console.WriteLine(json);

            dynamic read = json.JSONToDynamic();
            Assert.IsNotNull(read);

            Assert.AreEqual("v1", read.p1);
            Assert.AreEqual("v2", read.p2);
            Assert.AreEqual("149", read.Age);
        }
Example #9
0
        public static StringMap ParseQueryString(string url)
        {
			var items = new StringMap();

            // parse the querystring if needed
			if (url.Length > 0)
            {
                var querySegments = url.TrimStart('?').Split('&');
                foreach (string segment in querySegments)
                {
					string key;
					string value;

					var index = segment.IndexOf('=');
					if(index == -1)
					{
						key = segment;
						value = string.Empty;
					}
					else
					{
						key = segment.Substring(0, index);
						value = segment.Substring(index + 1);
					}

					items[UrlUtil.UrlDecode(key)] = UrlUtil.UrlDecode(value);
                }
            }

            return items;
        }
Example #10
0
        private void preapareArgs(ReportDefine reportDefine_0, Hashtable hashtable_0, Env env_0)
        {
            Args arguments = reportDefine_0.Arguments;

            if (arguments.size() > 0)
            {
                int num2 = arguments.size();
                for (int i = 0; i < num2; i++)
                {
                    Arg    arg = arguments[i];
                    string val = null;
                    if (hashtable_0 != null)
                    {
                        val = (string)hashtable_0[arg.enName];
                    }
                    if (((val == null) && (arg.value_Renamed != null)) && (arg.value_Renamed.Trim().Length > 0))
                    {
                        val = arg.value_Renamed;
                    }
                    int    num3       = int.Parse(arg.type);
                    object paramValue = null;
                    try
                    {
                        paramValue = ArgDataType.getProperData(num3, val);
                    }
                    catch (Exception)
                    {
                        throw new Exception(new StringBuilder("参数\"").Append(arg.chName).Append("\"的值").Append(val).Append("与其类型不匹配!").ToString().ToString());
                    }
                    env_0.putParam(arg.enName, paramValue);
                    _builder.Append("<arg><name>" + arg.enName + "</name><value>" + Convert.ToString(paramValue) + "</value></arg>");
                }
            }
            StringMap macros = reportDefine_0.Macros;

            if ((macros != null) && (macros.Count > 0))
            {
                IEnumerator enumerator = new SupportClass.SetSupport(macros.Keys).GetEnumerator();
                while (enumerator.MoveNext())
                {
                    string current = (string)enumerator.Current;
                    string str4    = null;
                    if (hashtable_0 != null)
                    {
                        str4 = (string)hashtable_0[current];
                    }
                    if (str4 == null)
                    {
                        str4 = (string)macros[current];
                    }
                    _builder.Append("<macro><name>" + current + "</name><value>" + str4 + "</value></macro>");
                    env_0.putMacro(current, str4);
                }
            }
            string str      = null;
            string rootPath = null;

            if (env_0.Request == null)
            {
                str      = env_0.getParameter("e_setparammacro");
                rootPath = FileAction.rootPath;
            }
            else
            {
                str      = env_0.Request["e_setparammacro"];
                rootPath = env_0.Request.PhysicalApplicationPath;
            }
            if ((str != null) && (str.Length > 0))
            {
                Type type = Assembly.LoadFrom(rootPath + @"bin\LoadEbiao.dll").GetType("LoadEbiao.IParamMacro");
                if (type != null)
                {
                    object[]     args       = new object[0];
                    object       obj2       = Activator.CreateInstance(type, args);
                    BindingFlags invokeAttr = BindingFlags.Public | BindingFlags.Instance;
                    object[]     parameters = new object[] { env_0 };
                    try
                    {
                        type.GetMethod("setParams").Invoke(obj2, invokeAttr, Type.DefaultBinder, parameters, null);
                    }
                    catch (Exception exception)
                    {
                        throw new Exception(exception.InnerException.Message);
                    }
                    try
                    {
                        type.GetMethod("setMacros").Invoke(obj2, invokeAttr, Type.DefaultBinder, parameters, null);
                    }
                    catch (Exception exception2)
                    {
                        throw new Exception(exception2.InnerException.Message);
                    }
                }
            }
        }
Example #11
0
        public void StringMap_Compact()
        {
            var map = new StringMap
            {
              {"p1", "v1"},
              {"p2", "v2"},
              {"Age", "149"}
            };

            var json = map.ToJSON(JSONWritingOptions.Compact);
            Console.WriteLine(json);

            Assert.AreEqual(@"{""p1"":""v1"",""p2"":""v2"",""Age"":""149""}",json);

            dynamic read = json.JSONToDynamic();
            Assert.IsNotNull(read);

            Assert.AreEqual("v1", read.p1);
            Assert.AreEqual("v2", read.p2);
            Assert.AreEqual("149", read.Age);
        }
        private void cboSelectedReview_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (UnsavedChanges)
            {
                DialogResult result = MessageBox.Show("There are unsaved changes. Are you sure you wish to change the selected review?", "Attention", MessageBoxButtons.YesNoCancel);

                if (result != DialogResult.Yes)
                {
                    return;
                }
            }

            if (cboSelectedReview.SelectedItem is string)
            {
                return;
            }

            Business.Entities.ProbationAnalysis probationAnalysis = (Business.Entities.ProbationAnalysis)((Utilities.ListItem)cboSelectedReview.SelectedItem).HiddenObject;
            txtRecognition.Text        = probationAnalysis.ProbationRecognition;
            txtHypothesis.Text         = probationAnalysis.Hypothesis;
            txtHypothesisSupport.Text  = probationAnalysis.HypothesisSupportandAnalysis;
            txtTemporaryPermanent.Text = probationAnalysis.TemporaryVsPermanent;
            txtConsiderations.Text     = probationAnalysis.SpecialConsiderations;
            txtRecommendation.Text     = probationAnalysis.Recommendations;
            cboRecommendedWord.Text    = probationAnalysis.RecommendedWordIdName;

            if (probationAnalysis.DateApproved == null)
            {
                txtDateApproved.Text = null;
            }
            else
            {
                txtDateApproved.Text = ((DateTime)probationAnalysis.DateApproved).ToString("MM/dd/yyyy");
            }

            if (probationAnalysis.DatePresented == null)
            {
                txtDatePresented.Text = null;
            }
            else
            {
                txtDatePresented.Text = ((DateTime)probationAnalysis.DatePresented).ToString("MM/dd/yyyy");
            }

            if (probationAnalysis.RecommendedWordId != null)
            {
                foreach (var item in cboRecommendedWord.Items)
                {
                    if (((Utilities.ListItem)item).HiddenObject is string || ((Utilities.ListItem)item).HiddenObject == null)
                    {
                        continue;
                    }

                    StringMap _stringMap = (StringMap)(((Utilities.ListItem)item).HiddenObject);
                    if (_stringMap.Value == probationAnalysis.RecommendedWordIdName)
                    {
                        cboRecommendedWord.SelectedItem = item;
                        break;
                    }
                }
            }
            else
            {
                cboRecommendedWord.SelectedIndex = 0;
            }

            if (probationAnalysis.TimeTableId != null)
            {
                foreach (var item in cboSelectedQuarter.Items)
                {
                    if (((Utilities.ListItem)item).HiddenObject is string || ((Utilities.ListItem)item).HiddenObject == null)
                    {
                        continue;
                    }

                    Business.Entities.TimeTable timeTable = (Business.Entities.TimeTable)(((Utilities.ListItem)item).HiddenObject);

                    if (timeTable.TimeTableId == (Guid)probationAnalysis.TimeTableId)
                    {
                        cboSelectedQuarter.SelectedItem = item;
                        break;
                    }
                }
            }
            else
            {
                cboSelectedQuarter.SelectedIndex = 0;
            }

            if (probationAnalysis.OwnerId != null)
            {
                foreach (var item in cboOwner.Items)
                {
                    if (((Utilities.ListItem)item).HiddenObject is string || ((Utilities.ListItem)item).HiddenObject == null)
                    {
                        continue;
                    }

                    User owner = (User)(((Utilities.ListItem)item).HiddenObject);

                    if (owner.UserId == (Guid)probationAnalysis.OwnerId)
                    {
                        cboOwner.SelectedItem = item;
                        break;
                    }
                }
            }
            else
            {
                cboOwner.SelectedIndex = 0;
            }

            UnsavedChanges = false;
        }
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(StringMap obj) {
   return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
 }
Example #14
0
        public void StringMap_Sensitive()
        {
            using (var ms = new MemoryStream())
              {
            var s = new SlimSerializer();

            var dIn = new StringMap
            {
              {"a", "Alex"},
              {"b", "Boris"}
            };

            s.Serialize(ms, dIn);
            ms.Seek(0, SeekOrigin.Begin);

            var dOut = (StringMap)s.Deserialize(ms);

            Assert.IsNotNull(dOut);

            Assert.IsTrue( dOut.CaseSensitive );
            Assert.AreEqual( 2, dOut.Count);
            Assert.AreEqual( "Alex", dOut["a"]);
            Assert.AreEqual( null, dOut["A"]);

            Assert.AreEqual( "Boris", dOut["b"]);
            Assert.AreEqual( null, dOut["B"]);
              }
        }
Example #15
0
 private byte[] GetNameBytes(Type t)
 {
     return(StringMap.GetCachedStringBytes(t, TypeName));
 }
 public StringMapEvents(StringMap This)
 {
     this.This = This;
 }
	void StatsBox() {
		BeginVertical("box"); {
			Label("Item Stats Options");
			numOptions = IntField("Number", numOptions);
			
			OptionsButtons();
			numOptions = (int)numOptions.Clamp(0, 100);
			
			removeAt = -1;
			moveDown = -1;
			moveUp = -1;
			
			while (numOptions > stats.Count) { stats.Add(new OptionEntry("blank", 0)); }
			while (numOptions < stats.Count) { stats.RemoveAt(stats.Count-1); }
			for (int i = 0; i < stats.Count; i++) { DrawOption(i); }
			
			if (removeAt >= 0) { 
				changed = true; 
				stats.RemoveAt(removeAt); 
			}
			if (moveDown >= 0 && moveDown < stats.Count-1) { 
				changed = true; 
				stats.Swap(moveDown, moveDown+1);
			}
			if (moveUp >= 1) { 
				changed = true; 
				stats.Swap(moveUp, moveUp-1); 
			}
			
			numOptions = stats.Count;
			
			OptionsButtons();
			
		} EndVertical();
		
		
		
		BeginVertical("box"); {
			Label("Item String Options");
			
			strings = StringMapField(strings, Item.DEFAULT_STRINGS);
			
			
		} EndVertical();
		
		
	}
Example #18
0
File: Proxy.cs Project: lulzzz/sito
        private void fillMembers()
        {
            lock (this)
            {
                if (_members != null)
                {
                    return;
                }

                var                tempMembers       = new StringMap <IList <MemberInfo> >();
                string             prewName          = null;
                IList <MemberInfo> temp              = null;
                bool               instanceAttribute = false;

                var members = _hostedType.GetMembers();

                for (int i = 0; i < members.Length; i++)
                {
                    var member = members[i];
                    if (member.IsDefined(typeof(HiddenAttribute), false))
                    {
                        continue;
                    }

                    instanceAttribute = member.IsDefined(typeof(InstanceMemberAttribute), false);

                    if (!IsInstancePrototype && instanceAttribute)
                    {
                        continue;
                    }

                    var property = member as PropertyInfo;
                    if (property != null)
                    {
                        if ((property.GetSetMethod(true) ?? property.GetGetMethod(true)).IsStatic != !(IsInstancePrototype ^ instanceAttribute))
                        {
                            continue;
                        }
                        if ((property.GetSetMethod(true) == null || !property.GetSetMethod(true).IsPublic) &&
                            (property.GetGetMethod(true) == null || !property.GetGetMethod(true).IsPublic))
                        {
                            continue;
                        }

                        var parentProperty = property;
                        while (parentProperty != null &&
                               parentProperty.DeclaringType != typeof(object) &&
                               ((property.GetGetMethod() ?? property.GetSetMethod()).Attributes & MethodAttributes.NewSlot) == 0)
                        {
                            property = parentProperty;
#if (PORTABLE)
                            parentProperty = property.DeclaringType.GetTypeInfo().BaseType?.GetRuntimeProperty(property.Name);
#else
                            parentProperty = property.DeclaringType.GetTypeInfo().BaseType?.GetProperty(property.Name, BindingFlags.Public | BindingFlags.Instance);
#endif
                        }

                        member = property;
                    }

                    if (member is EventInfo &&
                        (!(member as EventInfo).GetAddMethod(true).IsPublic || (member as EventInfo).GetAddMethod(true).IsStatic != !IsInstancePrototype))
                    {
                        continue;
                    }

                    if (member is FieldInfo && (!(member as FieldInfo).IsPublic || (member as FieldInfo).IsStatic != !IsInstancePrototype))
                    {
                        continue;
                    }
#if (PORTABLE)
                    if ((members[i] is TypeInfo) && !(members[i] as TypeInfo).IsPublic)
                    {
                        continue;
                    }
#else
                    if (member is Type && !(member as Type).IsPublic && !(member as Type).IsNestedPublic)
                    {
                        continue;
                    }
#endif
                    var method = member as MethodBase;
                    if (method != null)
                    {
                        if (method.IsStatic != !(IsInstancePrototype ^ instanceAttribute))
                        {
                            continue;
                        }
                        if (!method.IsPublic)
                        {
                            continue;
                        }
                        if (method.DeclaringType == typeof(object) && member.Name == "GetType")
                        {
                            continue;
                        }
                        if (method is ConstructorInfo)
                        {
                            continue;
                        }

                        if (method.IsVirtual && (method.Attributes & MethodAttributes.NewSlot) == 0)
                        {
                            var parameterTypes = method.GetParameters().Select(x => x.ParameterType).ToArray();
                            var parentMethod   = method;
                            while (parentMethod != null && parentMethod.DeclaringType != typeof(object) && (method.Attributes & MethodAttributes.NewSlot) == 0)
                            {
                                method = parentMethod;
#if (PORTABLE)
                                parentMethod = method.DeclaringType.GetTypeInfo().BaseType?.GetMethod(method.Name, parameterTypes);
#else
                                parentMethod = method.DeclaringType.BaseType?.GetMethod(method.Name, BindingFlags.Public | BindingFlags.Instance, null, parameterTypes, null);
#endif
                            }
                        }

                        member = method;
                    }

                    var membername = member.Name;
                    if (member.IsDefined(typeof(JavaScriptNameAttribute), false))
                    {
                        var nameOverrideAttribute = member.GetCustomAttributes(typeof(JavaScriptNameAttribute), false).ToArray();
                        membername = (nameOverrideAttribute[0] as JavaScriptNameAttribute).Name;
                    }
                    else
                    {
                        membername = membername[0] == '.' ? membername : membername.Contains(".") ? membername.Substring(membername.LastIndexOf('.') + 1) : membername;

#if (PORTABLE)
                        if (members[i] is TypeInfo && membername.Contains("`"))
#else
                        if (member is Type && membername.Contains('`'))
#endif
                        {
                            membername = membername.Substring(0, membername.IndexOf('`'));
                        }
                    }

                    if (prewName != membername)
                    {
                        if (temp != null && temp.Count > 1)
                        {
                            var type = temp[0].DeclaringType;
                            for (var j = 1; j < temp.Count; j++)
                            {
                                if (type != temp[j].DeclaringType && type.IsAssignableFrom(temp[j].DeclaringType))
                                {
                                    type = temp[j].DeclaringType;
                                }
                            }
                            int offset = 0;
                            for (var j = 1; j < temp.Count; j++)
                            {
                                if (!type.IsAssignableFrom(temp[j].DeclaringType))
                                {
                                    temp.RemoveAt(j--);
                                    tempMembers.Remove(prewName + "$" + (++offset + j));
                                }
                            }
                            if (temp.Count == 1)
                            {
                                tempMembers.Remove(prewName + "$0");
                            }
                        }
                        if (!tempMembers.TryGetValue(membername, out temp))
                        {
                            tempMembers[membername] = temp = new List <MemberInfo>();
                        }
                        prewName = membername;
                    }

                    if (membername.StartsWith("@@"))
                    {
                        if (_symbols == null)
                        {
                            _symbols = new Dictionary <Symbol, JSValue>();
                        }
                        _symbols.Add(Symbol.@for(membername.Substring(2)), proxyMember(false, new[] { member }));
                    }
                    else
                    {
                        if (temp.Count == 1)
                        {
                            tempMembers.Add(membername + "$0", new[] { temp[0] });
                        }

                        temp.Add(member);

                        if (temp.Count != 1)
                        {
                            tempMembers.Add(membername + "$" + (temp.Count - 1), new[] { member });
                        }
                    }
                }

                _members = tempMembers;

                if (IsInstancePrototype)
                {
                    if (typeof(IIterable).IsAssignableFrom(_hostedType))
                    {
                        IList <MemberInfo> iterator = null;
                        if (_members.TryGetValue("iterator", out iterator))
                        {
                            if (_symbols == null)
                            {
                                _symbols = new Dictionary <Symbol, JSValue>();
                            }
                            _symbols.Add(Symbol.iterator, proxyMember(false, iterator));
                            _members.Remove("iterator");
                        }
                    }
#if NET40
                    var toStringTag = _hostedType.GetCustomAttribute <ToStringTagAttribute>();
#else
                    var toStringTag = _hostedType.GetTypeInfo().GetCustomAttribute <ToStringTagAttribute>();
#endif
                    if (toStringTag != null)
                    {
                        if (_symbols == null)
                        {
                            _symbols = new Dictionary <Symbol, JSValue>();
                        }
                        _symbols.Add(Symbol.toStringTag, toStringTag.Tag);
                    }
                }

                if (_indexersSupported)
                {
                    IList <MemberInfo> getter = null;
                    IList <MemberInfo> setter = null;
                    _members.TryGetValue("get_Item", out getter);
                    _members.TryGetValue("set_Item", out setter);

                    if (getter != null || setter != null)
                    {
                        _indexerProperty = new PropertyPair();

                        if (getter != null)
                        {
                            _indexerProperty.getter = (Function)proxyMember(false, getter);
                            _fields["get_Item"]     = _indexerProperty.getter;
                        }

                        if (setter != null)
                        {
                            _indexerProperty.setter = (Function)proxyMember(false, setter);
                            _fields["set_Item"]     = _indexerProperty.setter;
                        }
                    }
                    else
                    {
                        _indexersSupported = false;
                    }
                }
            }
        }
 private void clearCache()
 {
     _formulaIdMap.Clear();
     StringMap.Clear();
     IdStringMap.Clear();
 }
Example #20
0
        public CosmosDbDataStore(
            string connectionString,
            string databaseId,
            string containerId,
            string keyMap,
            [Optional] IValidator <TKey, TValue> validator = null,
            [Optional] IReadOnlyList <IObserver <TKey, TValue> > typedObservers = null,
            [Optional] IReadOnlyList <IObserver> untypedObservers             = null,
            [Optional] IReadOnlyList <IMutator <TKey, TValue> > typedMutators = null,
            [Optional] IReadOnlyList <IMutator> untypedMutators = null)
        {
            _connectionString = connectionString;

            _databaseId = databaseId;

            _containerId = containerId;

            _container = new Lazy <Container>(() =>
                                              new CosmosClient(
                                                  connectionString: connectionString,
                                                  clientOptions: new CosmosClientOptions
            {
                AllowBulkExecution = false
            })
                                              .GetContainer(databaseId: databaseId,
                                                            containerId: containerId));

            _bulkContainer = new Lazy <Container>(() =>
                                                  new CosmosClient(
                                                      connectionString: connectionString,
                                                      clientOptions: new CosmosClientOptions
            {
                AllowBulkExecution = true
            })
                                                  .GetContainer(databaseId: databaseId,
                                                                containerId: containerId));

            _keyMap = keyMap;

            if (keyMap.Contains('|'))
            {
                var m = _partitionKeyMatcher.Match(keyMap);

                if (!m.Success)
                {
                    throw new ArgumentException("Unable to comprehend partition key in key map.");
                }

                _partitionKey = m.Groups["Key"].Value;

                if (typeof(IDocument).IsAssignableFrom(typeof(TValue)))
                {
                    var partitionKeyProperty = typeof(TValue).GetProperty(_partitionKey);

                    if (partitionKeyProperty == null)
                    {
                        throw new ArgumentException($"Type {typeof(TValue).Name} is missing partition key property '{_partitionKey}'");
                    }

                    if (partitionKeyProperty.PropertyType == typeof(Guid) ||
                        partitionKeyProperty.PropertyType == typeof(Guid?))
                    {
                        // Automagically set partition key guids to dashed

                        _keyMap = $"{{{_partitionKey}:D}}|{keyMap.Substring(m.Value.Length)}";
                    }
                }

                _keyMapWithoutPartitionKey = keyMap.Substring(m.Value.Length);
            }
            else
            {
                _keyMapWithoutPartitionKey = _keyMap;
            }

            _validator = validator;

            _typedObservers = typedObservers ?? EmptyReadOnlyList <IObserver <TKey, TValue> > .Instance;

            _untypedObservers = untypedObservers ?? EmptyReadOnlyList <IObserver> .Instance;

            _typedMutators = typedMutators ?? EmptyReadOnlyList <IMutator <TKey, TValue> > .Instance;

            _untypedMutators = untypedMutators ?? EmptyReadOnlyList <IMutator> .Instance;
        }
Example #21
0
 public void HostFoo(StringMap args)
 {
     Logger.Debug("HostFoo() called from script, args={0}", args);
 }
	public StringMap StringMapField(StringMap original, List<string> toIgnore) {
		
		StringMap newMap = new StringMap();
		BeginVertical("box"); {
		
			if (FixedButton("+")) {
				newMap["blank"+(original.Count-5)] = "";
				changed = changed || checkChanges;
			}
			
			foreach (string key in original.Keys) {
				if (toIgnore != null && toIgnore.Contains(key)) {
					newMap[key] = original[key];
				} else {
					BeginHorizontal(); {
						if (!FixedButton("-")) {
							string fieldName = key;
							string fieldValue = original[key];
							
							fieldName = TextField(fieldName, .3f);
							FixedLabel("-");
							fieldValue = TextField(fieldValue, .3f);
							
							newMap[fieldName] = fieldValue;
							
						} else {
							changed = changed || checkChanges;
						}
						
					} EndHorizontal();
				}
			}
			
			if (FixedButton("+")) {
				newMap["blank"+(original.Count-5)] = "";
				changed = changed || checkChanges;
			}
			
		} EndVertical();
		
		return newMap;
	}
	void LoadSelection() {
		editing = items[selection].Clone();
		stats = editing.stats.ToListOfOptions();
		strings = editing.strings.Clone();
		
		numOptions = stats.Count;
		//numStringOptions = strings.Count;
		
		changed = false;
	}
Example #24
0
 public IEqualityComparer <String> GetComparer()
 {
     return(StringMap.GetComparer(!this.Allow_CaseInsensitiveReferences));
 }
 internal static HandleRef getCPtr(StringMap obj)
 {
     return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
 }
Example #26
0
		public HttpRequest(string url)
		{
			this.Url = new Uri(url);
			this.queryValues = UrlUtil.ParseQueryString(this.Url.Query);
		}
Example #27
0
        public void TestWriteExternalAndPutGet()
        {
            StringMap[] m = new StringMap[4];
            SetUp(out m[0], out m[1], out m[2], out m[3]);

            for (int i = 0; i < m.Length; i++)
            {
                MemoryStream memoryBytes = new MemoryStream();
                m[i].WriteExternal(memoryBytes);
                memoryBytes.Position = 0;
                m[i] = new StringMap();
                m[i].ReadExternal(memoryBytes);
            }

            StringMap m0 = m[0];
            StringMap m1 = m[1];
            StringMap m5 = m[2];
            StringMap m5i = m[3];

            Assert.AreEqual("2", m5["abc"]);
            Assert.AreEqual(null, m5["aBc"]);
            Assert.AreEqual("2", m5i["abc"]);
            Assert.AreEqual("2", m5i["aBc"]);

            m5.Add(null, "x");
            m5.Add("aBc", "x");
            m5i.Add("AbC", "x");

            StringBuilder buffer = new StringBuilder();
            buffer.Append("aBc");
            Assert.AreEqual("2", m5["abc"]);
            Assert.AreEqual("x", m5[buffer]);
            Assert.AreEqual("x", m5i[(object)"abc"]);
            Assert.AreEqual("x", m5i["aBc"]);

            Assert.AreEqual("x", m5[null]);
            Assert.AreEqual("0", m5i[null]);
        }
	public StringMap StringMapField(StringMap original) { return StringMapField(original, null); }
Example #29
0
        public static MsCrmResultObject GetQuestionInfo(Guid questionId, SqlDataAccess sda)
        {
            MsCrmResultObject returnValue = new MsCrmResultObject();
            try
            {
                #region | SQL QUERY |
                string query = @"SELECT
                                    q.new_questionId AS Id
                                    ,q.new_name AS Name
                                    ,q.new_portalId AS PortalId
                                    ,q.new_portalIdName AS PortalIdName
                                    ,q.new_questionlevelId AS LevelId
                                    ,q.new_questionlevelIdName AS LevelIdName
                                    --,q.new_portal_rubic_cube_definitionid AS DefinationId
                                    --,q.new_portal_rubic_cube_definitionidName AS DefinationIdName
                                    ,q.new_category AS QuestionCategoryValue
                                    ,NULL AS QuestionCategoryName
                                    ,q.new_timecount AS [Time]
                                    ,q.new_point AS [Point]
                                FROM
                                    new_question AS q (NOLOCK)
                                WHERE
                                    q.new_questionId='{0}'
                                AND
                                    q.statecode=0
                                AND
                                    q.statuscode=1 --Active";
                #endregion

                DataTable dt = sda.getDataTable(string.Format(query, questionId));

                if (dt != null && dt.Rows.Count > 0)
                {
                    Question _question = new Question();
                    _question.Id = (Guid)dt.Rows[0]["Id"];
                    _question.Name = dt.Rows[0]["Name"] != DBNull.Value ? dt.Rows[0]["Name"].ToString() : string.Empty;

                    if (dt.Rows[0]["PortalId"] != DBNull.Value)
                    {
                        EntityReference er = new EntityReference()
                        {
                            Id = (Guid)dt.Rows[0]["PortalId"],
                            Name = dt.Rows[0]["PortalIdName"].ToString()
                        };

                        _question.Portal = er;
                    }

                    if (dt.Rows[0]["LevelId"] != DBNull.Value)
                    {
                        EntityReference er = new EntityReference()
                        {
                            Id = (Guid)dt.Rows[0]["LevelId"],
                            Name = dt.Rows[0]["LevelIdName"].ToString()
                        };

                        _question.QuestionLevel = er;
                    }

                    //if (dt.Rows[0]["DefinationId"] != DBNull.Value)
                    //{
                    //    EntityReference er = new EntityReference()
                    //    {
                    //        Id = (Guid)dt.Rows[0]["DefinationId"],
                    //        Name = dt.Rows[0]["DefinationIdName"].ToString()
                    //    };

                    //    _question.QuestionDefination = er;
                    //}

                    if (dt.Rows[0]["QuestionCategoryValue"] != DBNull.Value)
                    {
                        StringMap sm = new StringMap()
                        {
                            Value = (int)dt.Rows[0]["QuestionCategoryValue"],
                            Name = dt.Rows[0]["QuestionCategoryName"] != DBNull.Value ? dt.Rows[0]["QuestionCategoryName"].ToString() : string.Empty
                        };

                        _question.QuestionCategory = sm;
                    }

                    _question.Time = dt.Rows[0]["Time"] != DBNull.Value ? (int)dt.Rows[0]["Time"] : 0;
                    _question.Point = dt.Rows[0]["Point"] != DBNull.Value ? (int)dt.Rows[0]["Point"] : 0;

                    _question.QuestionChoices = (List<QuestionChoices>)GetQuestionChoices(_question.Id, sda).ReturnObject;

                    returnValue.Success = true;
                    returnValue.ReturnObject = _question;
                }
                else
                {
                    returnValue.Success = false;
                    returnValue.Result = "M028"; //"Soruya ait bilgi bulunamadı";
                }
            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Result = ex.Message;
            }
            return returnValue;
        }
Example #30
0
        public void TestWriteExternalAndTestSize()
        {
            StringMap[] m = new StringMap[4];
            SetUp(out m[0], out m[1], out m[2], out m[3]);

            for (int i = 0; i < m.Length; i++)
            {
                MemoryStream bout = new MemoryStream();
                m[i].WriteExternal(bout);
                bout.Position = 0;
                m[i] = new StringMap();
                m[i].ReadExternal(bout);
            }

            StringMap m0 = m[0];
            StringMap m1 = m[1];
            StringMap m5 = m[2];
            StringMap m5i = m[3];

            Assert.AreEqual(0, m0.Count);
            Assert.AreEqual(1, m1.Count);
            Assert.AreEqual(5, m5.Count);
            Assert.AreEqual(5, m5i.Count);

            m1.Remove("abc");
            m5.Remove("abc");
            m5.Add("bbb", "x");
            m5i.Add("ABC", "x");
            Assert.AreEqual(0, m0.Count);
            Assert.AreEqual(0, m1.Count);
            Assert.AreEqual(4, m5.Count);
            Assert.AreEqual(5, m5i.Count);
        }
	public void LoadXML( string name )
	{
		Serializer<StringMap> serializer = new Serializer<StringMap>();
		Map = serializer.Load(name);
	}
Example #32
0
        protected void SetUp(out StringMap m0,
            out StringMap m1,
            out StringMap m5,
            out StringMap m5i)
        {
            m0=new StringMap();
            m1=new StringMap(false);
            m1.Add("abc", "0");

            m5=new StringMap(false);
            m5.Add("a", "0");
            m5.Add("ab", "1");
            m5.Add("abc", "2");
            m5.Add("abb", "3");
            m5.Add("bbb", "4");

            m5i=new StringMap(true);
            m5i.Add(null, "0");
            m5i.Add("ab", "1");
            m5i.Add("abc", "2");
            m5i.Add("abb", "3");
            m5i.Add("bbb", null);
        }
Example #33
0
 /// <summary>
 /// StringMap
 /// </summary>
 private static void benchmark7(int size)
 {
     GC.Collect();
     var dictionary = new StringMap<int>();
     var keys = new string[size];
     for (int i = 0; i < keys.Length; i++)
         keys[i] = i.ToString();
     var sw = new Stopwatch();
     sw.Start();
     for (int i = 0; i < keys.Length; i++)
         dictionary.Add(keys[(long)i * psrandmul % keys.Length], (int)(((long)i * psrandmul) % keys.Length));
     sw.Stop();
     Console.WriteLine(sw.Elapsed);
     GC.GetTotalMemory(true);
     sw.Restart();
     foreach (var t in dictionary)
     {
         // System.Diagnostics.Debugger.Break(); // порядок не соблюдается. Проверка бессмыслена
     }
     sw.Stop();
     Console.WriteLine(sw.Elapsed);
     GC.GetTotalMemory(true);
     sw.Restart();
     for (int i = 0; i < keys.Length; i++)
     {
         if (dictionary[keys[i]] != i)
             throw new Exception();
     }
     sw.Stop();
     Console.WriteLine(sw.Elapsed);
     Console.WriteLine(StringMap<int>.missCount);
 }
Example #34
0
 /// <summary>
 /// A method that calls a Constructor which takes a StringMap
 /// <br>Satisfies interface <see cref="iDocType_Takes_StringMap{DocM690_MemberRecord}"/></br>
 /// </summary>
 /// <param name="stringMap">The stringmap to have turned into a Balance Forward record.</param>
 /// <param name="headers">The column headers</param>
 /// <returns></returns>
 public DocM690_MemberRecord GetT(StringMap stringMap, string[] headers)
 {
     return(new DocM690_MemberRecord(stringMap, headers));
 }