public object Clone() { Attrib attrib = new Attrib(); attrib.ID = ID != null ? (string) ID.Clone(): null; attrib.Name = Name != null ? (string) Name.Clone(): null; attrib.Type = Type != null ? (string) Type.Clone(): null; return attrib; }
public static Attrib[] GetClassAttributes(Hashtable attrib) { Attrib[] a = new Attrib[attrib.Count]; IDictionaryEnumerator enu = attrib.GetEnumerator(); int index = 0; Attrib attribValue=new Attrib(); while (enu.MoveNext()) { a[index] = new Attrib(); attribValue=(Attrib)enu.Value; a[index].Name = (string)attribValue.Name; a[index].ID = (string)attribValue.ID; a[index].Type = (string)attribValue.Type; index++; } return a; }
private static Hashtable GetIndexAttribute(Attrib attrib) { Hashtable settings = new Hashtable(); settings.Add("name", attrib.Name); settings.Add("data-type", attrib.Type); settings.Add("type", "attrib"); settings.Add("id", attrib.ID); return settings; }
private static Hashtable GetIndexAttributes(Attrib[] attributes) { Hashtable settings = new Hashtable(); foreach (Attrib attrib in attributes) settings.Add(attrib.ID, GetIndexAttribute(attrib)); return settings; }
private static Attrib GetIndexAttribute(Hashtable settings) { Attrib attrib = new Attrib(); if (settings.ContainsKey("id")) attrib.ID = settings["id"].ToString(); if (settings.ContainsKey("data-type")) attrib.Type = settings["data-type"].ToString(); if (settings.ContainsKey("name")) attrib.Name = settings["name"].ToString(); return attrib; }
private static Attrib[] GetIndexAttributes(Hashtable settings) { Attrib[] attributes = new Attrib[settings.Count]; int i = 0; foreach (Hashtable attrib in settings.Values) attributes[i++] = GetIndexAttribute(attrib); return attributes; }
public static Attrib[] GetClassAttributes(Hashtable attrib, System.Type type) { System.Collections.Generic.List<Attrib> a = new System.Collections.Generic.List<Attrib>(); IDictionaryEnumerator enu = attrib.GetEnumerator(); System.Reflection.PropertyInfo pi = null; System.Reflection.FieldInfo fi = null; string dt = null; string _unsupportedtypes = ""; bool _nonPrimitiveAttSpecified = false; while (enu.MoveNext()) { pi = type.GetProperty(enu.Key.ToString()); if(pi!=null) { dt = pi.PropertyType.FullName; } if (pi == null) { fi = type.GetField(enu.Key.ToString()); if(fi!=null) dt = fi.FieldType.FullName; } if (pi != null || fi != null) { Attrib tempAttrib = new Attrib(); tempAttrib.Name = (string)enu.Key; tempAttrib.ID = (string)enu.Value; tempAttrib.Type = dt; System.Type currentType =System.Type.GetType(dt); if (currentType != null && !currentType.IsPrimitive && currentType.FullName != "System.DateTime" && currentType.FullName != "System.String" && currentType.FullName != "System.Decimal") { _nonPrimitiveAttSpecified = true; _unsupportedtypes += currentType.FullName + "\n"; } if (currentType == null) { _nonPrimitiveAttSpecified = true; _unsupportedtypes += "Unknown Type\n"; } a.Add(tempAttrib); } else { string message = "Invalid class attribute(s) specified '" + enu.Key.ToString() + "'."; throw new Exception(message ); } pi = null; fi = null; } if (_nonPrimitiveAttSpecified) throw new Exception("NCache Queries only support primitive types. The following type(s) is/are not supported:\n"+_unsupportedtypes); return (Attrib[])a.ToArray(); }