本文整理汇总了C#中System.Xml.Serialization.XmlTypeMapMember类的典型用法代码示例。如果您正苦于以下问题:C# XmlTypeMapMember类的具体用法?C# XmlTypeMapMember怎么用?C# XmlTypeMapMember使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlTypeMapMember类属于System.Xml.Serialization命名空间,在下文中一共展示了XmlTypeMapMember类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: XmlTypeMapElementInfo
public XmlTypeMapElementInfo (XmlTypeMapMember member, TypeData type)
{
_member = member;
_type = type;
if (type.IsValueType && type.IsNullable)
_isNullable = true;
}
示例2: XmlMemberMapping
internal XmlMemberMapping (string memberName, string defaultNamespace, XmlTypeMapMember mapMem, bool encodedFormat)
{
_mapMember = mapMem;
_memberName = memberName;
if (mapMem is XmlTypeMapMemberAnyElement)
{
XmlTypeMapMemberAnyElement anyelem = (XmlTypeMapMemberAnyElement) mapMem;
XmlTypeMapElementInfo info = (XmlTypeMapElementInfo) anyelem.ElementInfo[anyelem.ElementInfo.Count-1];
_elementName = info.ElementName;
_namespace = info.Namespace;
if (info.MappedType != null) _typeNamespace = info.MappedType.Namespace;
else _typeNamespace = "";
}
else if (mapMem is XmlTypeMapMemberElement)
{
XmlTypeMapElementInfo info = (XmlTypeMapElementInfo) ((XmlTypeMapMemberElement)mapMem).ElementInfo[0];
_elementName = info.ElementName;
if (encodedFormat)
{
_namespace = defaultNamespace;
if (info.MappedType != null) _typeNamespace = "";
else _typeNamespace = info.DataTypeNamespace;
}
else
{
_namespace = info.Namespace;
if (info.MappedType != null) _typeNamespace = info.MappedType.Namespace;
else _typeNamespace = "";
_form = info.Form;
}
}
else
{
_elementName = _memberName;
_namespace = "";
}
if (_form == XmlSchemaForm.None)
_form = XmlSchemaForm.Qualified;
}
示例3: IsReadOnly
bool IsReadOnly (XmlTypeMapping map, XmlTypeMapMember member, TypeData memType, bool isValueList)
{
if (isValueList) return !memType.HasPublicConstructor;
else return member.IsReadOnly (map.TypeData.Type) || !memType.HasPublicConstructor;
}
示例4: CreateFieldMember
CodeTypeMember CreateFieldMember (CodeTypeDeclaration codeClass, XmlTypeMapMember member)
{
return CreateFieldMember (codeClass, GetDomType (member.TypeData, member.RequiresNullable), member.Name, member.DefaultValue, member.TypeData, member.Documentation);
}
示例5: GenerateMemberHasValueCondition
string GenerateMemberHasValueCondition (XmlTypeMapMember member, string ob, bool isValueList)
{
if (isValueList) {
if (member.IsOptionalValueType)
return ob + ".Length > " + Math.Max (member.GlobalIndex, member.SpecifiedGlobalIndex) + " && " + GetCast (typeof(bool), ob + "[" + member.SpecifiedGlobalIndex + "]");
else
return ob + ".Length > " + member.GlobalIndex;
}
else if (member.DefaultValue != System.DBNull.Value) {
string mem = ob + "[email protected]" + member.Name;
if (member.DefaultValue == null)
return mem + " != null";
else if (member.TypeData.SchemaType == SchemaTypes.Enum)
return mem + " != " + GetCast (member.TypeData, GetLiteral (member.DefaultValue));
else
return mem + " != " + GetLiteral (member.DefaultValue);
}
else if (member.IsOptionalValueType)
return ob + "[email protected]" + member.Name + "Specified";
return null;
}
示例6: CreateElementInfo
XmlTypeMapElementInfo CreateElementInfo (string ns, XmlTypeMapMember member, string name, TypeData typeData, bool isNillable, XmlSchemaForm form, int order)
{
if (typeData.IsComplexType)
return CreateElementInfo (ns, member, name, typeData, isNillable, form, GetTypeMapping (typeData), order);
else
return CreateElementInfo (ns, member, name, typeData, isNillable, form, null, order);
}
示例7: CreateTextElementInfo
XmlTypeMapElementInfo CreateTextElementInfo (string ns, XmlTypeMapMember member, TypeData typeData)
{
XmlTypeMapElementInfo einfo = new XmlTypeMapElementInfo (member, typeData);
einfo.IsTextElement = true;
einfo.WrappedElement = false;
if (typeData.IsComplexType)
einfo.MappedType = GetTypeMapping (typeData);
return einfo;
}
示例8: CreateFieldMember
CodeMemberField CreateFieldMember (XmlTypeMapMember member)
{
CodeMemberField codeField = new CodeMemberField (GetDomType (member.TypeData), member.Name);
codeField.Attributes = MemberAttributes.Public;
AddComments (codeField, member.Documentation);
if (member.DefaultValue != System.DBNull.Value)
GenerateDefaultAttribute (codeField, member.TypeData, member.DefaultValue);
return codeField;
}
示例9: AddMember
public void AddMember (XmlTypeMapMember member)
{
// If GlobalIndex has not been set, set it now
if (member.GlobalIndex == -1)
member.GlobalIndex = _allMembers.Count;
_allMembers.Add (member);
if (!(member.DefaultValue is System.DBNull) && member.DefaultValue != null) {
if (_membersWithDefault == null) _membersWithDefault = new ArrayList ();
_membersWithDefault.Add (member);
}
if (member.IsReturnValue)
_returnMember = member;
if (member is XmlTypeMapMemberAttribute)
{
XmlTypeMapMemberAttribute atm = (XmlTypeMapMemberAttribute)member;
if (_attributeMembers == null) _attributeMembers = new Hashtable();
string key = BuildKey (atm.AttributeName, atm.Namespace, -1);
if (_attributeMembers.ContainsKey (key))
throw new InvalidOperationException ("The XML attribute named '" + atm.AttributeName + "' from namespace '" + atm.Namespace + "' is already present in the current scope. Use XML attributes to specify another XML name or namespace for the attribute.");
member.Index = _attributeMembers.Count;
_attributeMembers.Add (key, member);
return;
}
else if (member is XmlTypeMapMemberFlatList)
{
RegisterFlatList ((XmlTypeMapMemberFlatList)member);
}
else if (member is XmlTypeMapMemberAnyElement)
{
XmlTypeMapMemberAnyElement mem = (XmlTypeMapMemberAnyElement) member;
if (mem.IsDefaultAny) _defaultAnyElement = mem;
if (mem.TypeData.IsListType) RegisterFlatList (mem);
}
else if (member is XmlTypeMapMemberAnyAttribute)
{
_defaultAnyAttribute = (XmlTypeMapMemberAnyAttribute) member;
return;
}
else if (member is XmlTypeMapMemberNamespaces)
{
_namespaceDeclarations = (XmlTypeMapMemberNamespaces) member;
return;
}
if (member is XmlTypeMapMemberElement && ((XmlTypeMapMemberElement)member).IsXmlTextCollector)
{
if (_xmlTextCollector != null) throw new InvalidOperationException ("XmlTextAttribute can only be applied once in a class");
_xmlTextCollector = member;
}
if (_elementMembers == null) {
_elementMembers = new ArrayList();
_elements = new Hashtable();
}
member.Index = _elementMembers.Count;
_elementMembers.Add (member);
ICollection elemsInfo = ((XmlTypeMapMemberElement)member).ElementInfo;
foreach (XmlTypeMapElementInfo elem in elemsInfo)
{
string key = BuildKey (elem.ElementName, elem.Namespace, elem.ExplicitOrder);
if (_elements.ContainsKey (key))
throw new InvalidOperationException ("The XML element named '" + elem.ElementName + "' from namespace '" + elem.Namespace + "' is already present in the current scope. Use XML attributes to specify another XML name or namespace for the element.");
_elements.Add (key, elem);
}
if (member.TypeData.IsListType && member.TypeData.Type != null && !member.TypeData.Type.IsArray) {
if (_listMembers == null) _listMembers = new ArrayList ();
_listMembers.Add (member);
}
}
示例10: DefinedInBaseMap
bool DefinedInBaseMap (XmlTypeMapping map, XmlTypeMapMember member)
{
if (((ClassMap)map.ObjectMap).FindMember (member.Name) != null)
return true;
else if (map.BaseMap != null)
return DefinedInBaseMap (map.BaseMap, member);
else
return false;
}
示例11: GenerateSetMemberValueFromAttr
void GenerateSetMemberValueFromAttr (XmlTypeMapMember member, string ob, string value, bool isValueList)
{
// Enumeration values specified in custom attributes are stored as integer
// values if the custom attribute property is of type object. So, it is
// necessary to convert to the enum type before asigning the value to the field.
if (member.TypeData.Type.IsEnum)
value = GetCast (member.TypeData.Type, value);
GenerateSetMemberValue (member, ob, value, isValueList, true);
}
示例12: IsReadOnly
bool IsReadOnly (XmlTypeMapMember member, TypeData memType, object ob, bool isValueList)
{
if (isValueList) return !memType.HasPublicConstructor;
else return member.IsReadOnly (ob.GetType()) || !memType.HasPublicConstructor;
}
示例13: SetMemberValue
void SetMemberValue (XmlTypeMapMember member, object ob, object value, bool isValueList)
{
if (isValueList) ((object[])ob)[member.GlobalIndex] = value;
else {
member.SetValue (ob, value);
if (member.IsOptionalValueType)
member.SetValueSpecified (ob, true);
}
}
示例14: GenerateSetMemberValue
void GenerateSetMemberValue (XmlTypeMapMember member, string ob, string value, bool isValueList)
{
if (isValueList) WriteLine (ob + "[" + member.GlobalIndex + "] = " + value + ";");
else {
WriteLine (ob + "[email protected]" + member.Name + " = " + value + ";");
if (member.IsOptionalValueType)
WriteLine (ob + "." + member.Name + "Specified = true;");
}
}
示例15: XmlTypeMapElementInfo
public XmlTypeMapElementInfo (XmlTypeMapMember member, TypeData type)
{
_member = member;
_type = type;
}