/// <summary> /// 获取字段信息 /// </summary> /// <param name="field"></param> /// <returns></returns> private Xml.Node get(FieldInfo field) { if (field != null) { Xml.Node node; if (fieldLock.TryGetValue(field, out node)) { return(node); } try { HashString fieldName; byte * buffer = UnmanagedPool.Default.Get(); try { using (fieldNameStream) { fieldNameStream.Reset(buffer, UnmanagedPool.DefaultSize); AutoCSer.Extension.TypeCodeGenerator.NameBuilder nameBuilder = new AutoCSer.Extension.TypeCodeGenerator.NameBuilder { NameStream = fieldNameStream, IsXml = true }; nameBuilder.Xml(field.DeclaringType); fieldNameStream.Write('.'); fieldNameStream.SimpleWriteNotNull(field.Name); fieldName = fieldNameStream.ToString(); } } finally { UnmanagedPool.Default.Push(buffer); } if (fields.TryGetValue(fieldName, out node)) { fields.Remove(fieldName); } fieldLock.Set(field, node); } finally { fieldLock.Exit(); } return(node); } return(default(Xml.Node)); }
/// <summary> /// 获取属性信息 /// </summary> /// <param name="property"></param> /// <returns></returns> private Xml.Node get(PropertyInfo property) { if (property != null) { Xml.Node node; if (propertyLock.TryGetValue(property, out node)) { return(node); } try { HashString propertyName; byte * buffer = UnmanagedPool.Default.Get(); try { using (propertyNameStream) { propertyNameStream.Reset(buffer, UnmanagedPool.DefaultSize); AutoCSer.Extension.TypeCodeGenerator.NameBuilder nameBuilder = new AutoCSer.Extension.TypeCodeGenerator.NameBuilder { NameStream = propertyNameStream, IsXml = true }; nameBuilder.Xml(property.DeclaringType); propertyNameStream.Write('.'); propertyNameStream.SimpleWriteNotNull(property.Name); propertyName = propertyNameStream.ToString(); } } finally { UnmanagedPool.Default.Push(buffer); } if (properties.TryGetValue(propertyName, out node)) { properties.Remove(propertyName); } propertyLock.Set(property, node); } finally { propertyLock.Exit(); } return(node); } return(default(Xml.Node)); }
/// <summary> /// 获取类型信息 /// </summary> /// <param name="type"></param> /// <returns></returns> private Xml.Node get(Type type) { if (type != null) { Xml.Node node; if (typeLock.TryGetValue(type, out node)) { return(node); } try { HashString typeName; byte * buffer = UnmanagedPool.Default.Get(); try { using (typeNameStream) { typeNameStream.Reset(buffer, UnmanagedPool.DefaultSize); AutoCSer.Extension.TypeCodeGenerator.NameBuilder nameBuilder = new AutoCSer.Extension.TypeCodeGenerator.NameBuilder { NameStream = typeNameStream, IsXml = true }; nameBuilder.Xml(type); typeName = typeNameStream.ToString(); } } finally { UnmanagedPool.Default.Push(buffer); } if (types.TryGetValue(typeName, out node)) { types.Remove(typeName); } typeLock.Set(type, node); } finally { typeLock.Exit(); } return(node); } return(default(Xml.Node)); }
/// <summary> /// 获取方法信息 /// </summary> /// <param name="method"></param> /// <returns></returns> private Xml.Node get(MethodInfo method) { if (method != null) { Xml.Node node; if (methodLock.TryGetValue(method, out node)) { return(node); } try { HashString methodName; byte * buffer = UnmanagedPool.Default.Get(); try { using (methodNameStream) { methodNameStream.Reset(buffer, UnmanagedPool.DefaultSize); AutoCSer.Extension.TypeCodeGenerator.NameBuilder nameBuilder = new AutoCSer.Extension.TypeCodeGenerator.NameBuilder { NameStream = methodNameStream, IsXml = true }; nameBuilder.Xml(method.DeclaringType); methodNameStream.Write('.'); string name = method.Name; if (name[0] == '.') { methodNameStream.Write('#'); methodNameStream.Write(new SubString { String = name, StartIndex = 1, Length = name.Length - 1 }); } else { methodNameStream.SimpleWriteNotNull(name); } ParameterInfo[] parameters = method.GetParameters(); if (parameters.Length != 0) { bool isFirst = true; methodNameStream.Write('('); foreach (ParameterInfo parameter in parameters) { if (isFirst) { isFirst = false; } else { methodNameStream.Write(','); } nameBuilder.Xml(parameter.ParameterType); } methodNameStream.Write(')'); } formatName(methodNameStream.Char, methodNameStream.CurrentChar); methodName = methodNameStream.ToString(); } } finally { UnmanagedPool.Default.Push(buffer); } if (methods.TryGetValue(methodName, out node)) { methods.Remove(methodName); } methodLock.Set(method, node); } finally { methodLock.Exit(); } return(node); } return(default(Xml.Node)); }