本文整理汇总了C#中global.GetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# global.GetAttribute方法的具体用法?C# global.GetAttribute怎么用?C# global.GetAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类global
的用法示例。
在下文中一共展示了global.GetAttribute方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateInstance
/// <summary>
/// This method creates an instance of AblaufbausteinShape based on the tag currently pointed by the reader. The reader is guaranteed (by the caller)
/// to be pointed at a serialized instance of AblaufbausteinShape.
/// </summary>
/// <remarks>
/// The caller will guarantee that the reader is positioned at open XML tag of the ModelRoot instance being read. This method should
/// not move the reader; the reader should remain at the same position when this method returns.
/// </remarks>
/// <param name="serializationContext">Serialization context.</param>
/// <param name="reader">XmlReader to read serialized data from.</param>
/// <param name="partition">Partition in which new AblaufbausteinShape instance should be created.</param>
/// <returns>Created AblaufbausteinShape instance.</returns>
protected override ModelElement CreateInstance(SerializationContext serializationContext, global::System.Xml.XmlReader reader, Partition partition)
{
string idStr = reader.GetAttribute("Id");
try
{
global::System.Guid id;
if (string.IsNullOrEmpty(idStr))
{ // Create a default Id.
id = global::System.Guid.NewGuid();
TestDslDefinitionSerializationBehaviorSerializationMessages.MissingId(serializationContext, reader, id);
}
else
{
id = new global::System.Guid(idStr);
}
string elementIdStr = reader.GetAttribute("internalElementId");
if (string.IsNullOrEmpty(elementIdStr))
{
return null;
}
else
{
global::System.Guid elementId = new global::System.Guid(elementIdStr);
ModelElement element = null;
if (elementId != System.Guid.Empty)
element = partition.ElementDirectory.FindElement(elementId);
if (element == null || !(element is IDomainModelOwnable))
return null;
return (element as IDomainModelOwnable).GetDomainModelServices().TopMostService.ShapeProvider.CreateShapeForElement(this.GetShapeClassId(), element,
new PropertyAssignment[]{ new PropertyAssignment(ElementFactory.IdPropertyAssignment, id)});
}
}
catch (global::System.ArgumentNullException /* anEx */)
{
TestDslDefinitionSerializationBehaviorSerializationMessages.InvalidPropertyValue(serializationContext, reader, "Id", typeof(global::System.Guid), idStr);
}
catch (global::System.FormatException /* fEx */)
{
TestDslDefinitionSerializationBehaviorSerializationMessages.InvalidPropertyValue(serializationContext, reader, "Id", typeof(global::System.Guid), idStr);
}
catch (global::System.OverflowException /* ofEx */)
{
TestDslDefinitionSerializationBehaviorSerializationMessages.InvalidPropertyValue(serializationContext, reader, "Id", typeof(global::System.Guid), idStr);
}
return null;
}
示例2: CreateInstance
/// <summary>
/// This method creates an instance of DesignerDiagram based on the tag currently pointed by the reader. The reader is guaranteed (by the caller)
/// to be pointed at a serialized instance of DesignerDiagram.
/// </summary>
/// <remarks>
/// The caller will guarantee that the reader is positioned at open XML tag of the ModelRoot instance being read. This method should
/// not move the reader; the reader should remain at the same position when this method returns.
/// </remarks>
/// <param name="serializationContext">Serialization context.</param>
/// <param name="reader">XmlReader to read serialized data from.</param>
/// <param name="partition">Partition in which new DesignerDiagram instance should be created.</param>
/// <returns>Created DesignerDiagram instance.</returns>
protected override DslModeling::ModelElement CreateInstance(DslModeling::SerializationContext serializationContext, global::System.Xml.XmlReader reader, DslModeling::Partition partition)
{
string idStr = reader.GetAttribute ("Id");
try
{
global::System.Guid id;
if (string.IsNullOrEmpty(idStr))
{ // Create a default Id.
id = global::System.Guid.NewGuid();
FamilyTreeDSLSerializationBehaviorSerializationMessages.MissingId(serializationContext, reader, id);
}
else
{
id = new global::System.Guid (idStr);
}
return new DesignerDiagram(partition, new DslModeling::PropertyAssignment(DslModeling::ElementFactory.IdPropertyAssignment, id));
}
catch (global::System.ArgumentNullException /* anEx */)
{
FamilyTreeDSLSerializationBehaviorSerializationMessages.InvalidPropertyValue(serializationContext, reader, "Id", typeof(global::System.Guid), idStr);
}
catch (global::System.FormatException /* fEx */)
{
FamilyTreeDSLSerializationBehaviorSerializationMessages.InvalidPropertyValue(serializationContext, reader, "Id", typeof(global::System.Guid), idStr);
}
catch (global::System.OverflowException /* ofEx */)
{
FamilyTreeDSLSerializationBehaviorSerializationMessages.InvalidPropertyValue(serializationContext, reader, "Id", typeof(global::System.Guid), idStr);
}
return null;
}
示例3: TryGetEncoding
/// <summary>
/// Attempts to return the encoding used by the reader.
/// </summary>
/// <remarks>
/// The reader will be positioned at the start of the document when calling this method.
/// </remarks>
protected virtual bool TryGetEncoding(global::System.Xml.XmlReader reader, out global::System.Text.Encoding encoding)
{
global::System.Diagnostics.Debug.Assert(reader.NodeType == System.Xml.XmlNodeType.XmlDeclaration, "reader should be at the XmlDeclaration node when calling this method");
encoding = null;
// Attempt to read and parse the "encoding" attribute from the XML declaration node
if (reader.NodeType == global::System.Xml.XmlNodeType.XmlDeclaration)
{
string encodingName = reader.GetAttribute("encoding");
if (!string.IsNullOrWhiteSpace(encodingName))
{
encoding = global::System.Text.Encoding.GetEncoding(encodingName);
return true;
}
}
return false;
}
示例4: ReadPropertiesFromAttributes
protected override void ReadPropertiesFromAttributes(DslModeling::SerializationContext serializationContext, DslModeling::ModelElement element, global::System.Xml.XmlReader reader)
{
base.ReadPropertiesFromAttributes(serializationContext, element, reader);
Operation instanceOfOperation = element as Operation;
global::System.Diagnostics.Debug.Assert(instanceOfOperation != null, "Expecting an instance of Operation");
// Signature
if (!serializationContext.Result.Failed)
{
string attribSignature = reader.GetAttribute("signature");
if (attribSignature != null)
{
global::System.String valueOfSignature;
if (DslModeling::SerializationUtilities.TryGetValue<global::System.String>(DslModeling::SerializationUtilities.UnescapeXmlString(attribSignature), out valueOfSignature))
{
instanceOfOperation.Signature = valueOfSignature;
}
else
{ // Invalid property value, ignored.
LinqToRdfSerializationBehaviorSerializationMessages.IgnoredPropertyValue(serializationContext, reader, "signature", typeof(global::System.String), attribSignature);
}
}
}
// Concurrency
if (!serializationContext.Result.Failed)
{
string attribConcurrency = reader.GetAttribute("concurrency");
if (attribConcurrency != null)
{
OperationConcurrency valueOfConcurrency;
if (DslModeling::SerializationUtilities.TryGetValue<OperationConcurrency>(DslModeling::SerializationUtilities.UnescapeXmlString(attribConcurrency), out valueOfConcurrency))
{
instanceOfOperation.Concurrency = valueOfConcurrency;
}
else
{ // Invalid property value, ignored.
LinqToRdfSerializationBehaviorSerializationMessages.IgnoredPropertyValue(serializationContext, reader, "concurrency", typeof(OperationConcurrency), attribConcurrency);
}
}
}
// Precondition
if (!serializationContext.Result.Failed)
{
string attribPrecondition = reader.GetAttribute("precondition");
if (attribPrecondition != null)
{
global::System.String valueOfPrecondition;
if (DslModeling::SerializationUtilities.TryGetValue<global::System.String>(DslModeling::SerializationUtilities.UnescapeXmlString(attribPrecondition), out valueOfPrecondition))
{
instanceOfOperation.Precondition = valueOfPrecondition;
}
else
{ // Invalid property value, ignored.
LinqToRdfSerializationBehaviorSerializationMessages.IgnoredPropertyValue(serializationContext, reader, "precondition", typeof(global::System.String), attribPrecondition);
}
}
}
// Postcondition
if (!serializationContext.Result.Failed)
{
string attribPostcondition = reader.GetAttribute("postcondition");
if (attribPostcondition != null)
{
global::System.String valueOfPostcondition;
if (DslModeling::SerializationUtilities.TryGetValue<global::System.String>(DslModeling::SerializationUtilities.UnescapeXmlString(attribPostcondition), out valueOfPostcondition))
{
instanceOfOperation.Postcondition = valueOfPostcondition;
}
else
{ // Invalid property value, ignored.
LinqToRdfSerializationBehaviorSerializationMessages.IgnoredPropertyValue(serializationContext, reader, "postcondition", typeof(global::System.String), attribPostcondition);
}
}
}
}
示例5: CheckVersion
/// <summary>
/// Checks the version of the file being read.
/// </summary>
/// <param name="serializationContext">Serialization context.</param>
/// <param name="reader">Reader for the file being read. The reader is positioned at the open tag of the root element being read.</param>
protected virtual void CheckVersion(DslModeling::SerializationContext serializationContext, global::System.Xml.XmlReader reader)
{
#region Check Parameters
global::System.Diagnostics.Debug.Assert(serializationContext != null);
if (serializationContext == null)
throw new global::System.ArgumentNullException("serializationContext");
global::System.Diagnostics.Debug.Assert(reader != null);
if (reader == null)
throw new global::System.ArgumentNullException("reader");
#endregion
global::System.Version expectedVersion = new global::System.Version("1.0.0.0");
string dslVersionStr = reader.GetAttribute("dslVersion");
if (dslVersionStr != null)
{
try
{
global::System.Version actualVersion = new global::System.Version(dslVersionStr);
if (actualVersion != expectedVersion)
{
HostDesignerSerializationBehaviorSerializationMessages.VersionMismatch(serializationContext, reader, expectedVersion, actualVersion);
}
}
catch (global::System.ArgumentException)
{
HostDesignerSerializationBehaviorSerializationMessages.InvalidPropertyValue(serializationContext, reader, "dslVersion", typeof(global::System.Version), dslVersionStr);
}
catch (global::System.FormatException)
{
HostDesignerSerializationBehaviorSerializationMessages.InvalidPropertyValue(serializationContext, reader, "dslVersion", typeof(global::System.Version), dslVersionStr);
}
catch (global::System.OverflowException)
{
HostDesignerSerializationBehaviorSerializationMessages.InvalidPropertyValue(serializationContext, reader, "dslVersion", typeof(global::System.Version), dslVersionStr);
}
}
}
示例6: ReadPropertiesFromAttributes
protected virtual void ReadPropertiesFromAttributes(DslModeling::SerializationContext serializationContext, DslModeling::ModelElement element, global::System.Xml.XmlReader reader)
{
Model instanceOfModel = element as Model;
global::System.Diagnostics.Debug.Assert(instanceOfModel != null, "Expecting an instance of Model");
// UseNullables
if (!serializationContext.Result.Failed)
{
string attribUseNullables = reader.GetAttribute("useNullables");
if (attribUseNullables != null)
{
NullableUsage valueOfUseNullables;
if (DslModeling::SerializationUtilities.TryGetValue<NullableUsage>(DslModeling::SerializationUtilities.UnescapeXmlString(attribUseNullables), out valueOfUseNullables))
{
instanceOfModel.UseNullables = valueOfUseNullables;
}
else
{ // Invalid property value, ignored.
ActiveWriterSerializationBehaviorSerializationMessages.IgnoredPropertyValue(serializationContext, reader, "useNullables", typeof(NullableUsage), attribUseNullables);
}
}
}
// CaseOfPrivateFields
if (!serializationContext.Result.Failed)
{
string attribCaseOfPrivateFields = reader.GetAttribute("caseOfPrivateFields");
if (attribCaseOfPrivateFields != null)
{
FieldCase valueOfCaseOfPrivateFields;
if (DslModeling::SerializationUtilities.TryGetValue<FieldCase>(DslModeling::SerializationUtilities.UnescapeXmlString(attribCaseOfPrivateFields), out valueOfCaseOfPrivateFields))
{
instanceOfModel.CaseOfPrivateFields = valueOfCaseOfPrivateFields;
}
else
{ // Invalid property value, ignored.
ActiveWriterSerializationBehaviorSerializationMessages.IgnoredPropertyValue(serializationContext, reader, "caseOfPrivateFields", typeof(FieldCase), attribCaseOfPrivateFields);
}
}
}
// GenerateMonoRailProject
if (!serializationContext.Result.Failed)
{
string attribGenerateMonoRailProject = reader.GetAttribute("generateMonoRailProject");
if (attribGenerateMonoRailProject != null)
{
global::System.Boolean valueOfGenerateMonoRailProject;
if (DslModeling::SerializationUtilities.TryGetValue<global::System.Boolean>(DslModeling::SerializationUtilities.UnescapeXmlString(attribGenerateMonoRailProject), out valueOfGenerateMonoRailProject))
{
instanceOfModel.GenerateMonoRailProject = valueOfGenerateMonoRailProject;
}
else
{ // Invalid property value, ignored.
ActiveWriterSerializationBehaviorSerializationMessages.IgnoredPropertyValue(serializationContext, reader, "generateMonoRailProject", typeof(global::System.Boolean), attribGenerateMonoRailProject);
}
}
}
// MonoRailProjectName
if (!serializationContext.Result.Failed)
{
string attribMonoRailProjectName = reader.GetAttribute("monoRailProjectName");
if (attribMonoRailProjectName != null)
{
global::System.String valueOfMonoRailProjectName;
if (DslModeling::SerializationUtilities.TryGetValue<global::System.String>(DslModeling::SerializationUtilities.UnescapeXmlString(attribMonoRailProjectName), out valueOfMonoRailProjectName))
{
instanceOfModel.MonoRailProjectName = valueOfMonoRailProjectName;
}
else
{ // Invalid property value, ignored.
ActiveWriterSerializationBehaviorSerializationMessages.IgnoredPropertyValue(serializationContext, reader, "monoRailProjectName", typeof(global::System.String), attribMonoRailProjectName);
}
}
}
// MonoRailProjectPath
if (!serializationContext.Result.Failed)
{
string attribMonoRailProjectPath = reader.GetAttribute("monoRailProjectPath");
if (attribMonoRailProjectPath != null)
{
global::System.String valueOfMonoRailProjectPath;
if (DslModeling::SerializationUtilities.TryGetValue<global::System.String>(DslModeling::SerializationUtilities.UnescapeXmlString(attribMonoRailProjectPath), out valueOfMonoRailProjectPath))
{
instanceOfModel.MonoRailProjectPath = valueOfMonoRailProjectPath;
}
else
{ // Invalid property value, ignored.
ActiveWriterSerializationBehaviorSerializationMessages.IgnoredPropertyValue(serializationContext, reader, "monoRailProjectPath", typeof(global::System.String), attribMonoRailProjectPath);
}
}
}
// MonoRailDefaultLayout
if (!serializationContext.Result.Failed)
{
string attribMonoRailDefaultLayout = reader.GetAttribute("monoRailDefaultLayout");
if (attribMonoRailDefaultLayout != null)
{
global::System.String valueOfMonoRailDefaultLayout;
if (DslModeling::SerializationUtilities.TryGetValue<global::System.String>(DslModeling::SerializationUtilities.UnescapeXmlString(attribMonoRailDefaultLayout), out valueOfMonoRailDefaultLayout))
{
instanceOfModel.MonoRailDefaultLayout = valueOfMonoRailDefaultLayout;
//.........这里部分代码省略.........
示例7: CheckVersion
/// <summary>
/// Checks the version of the file being read.
/// </summary>
/// <param name="serializationContext">Serialization context.</param>
/// <param name="reader">Reader for the file being read. The reader is positioned at the open tag of the root element being read.</param>
private static void CheckVersion(DslModeling::SerializationContext serializationContext, global::System.Xml.XmlReader reader)
{
global::System.Version expectedVersion = new global::System.Version("1.0.0.0");
string dslVersionStr = reader.GetAttribute("dslVersion");
if (dslVersionStr != null)
{
try
{
global::System.Version actualVersion = new global::System.Version(dslVersionStr);
if (actualVersion != expectedVersion)
{
AsyncDslSerializationBehaviorSerializationMessages.VersionMismatch(serializationContext, reader, expectedVersion, actualVersion);
}
}
catch (global::System.ArgumentException)
{
AsyncDslSerializationBehaviorSerializationMessages.InvalidPropertyValue(serializationContext, reader, "dslVersion", typeof(global::System.Version), dslVersionStr);
}
catch (global::System.FormatException)
{
AsyncDslSerializationBehaviorSerializationMessages.InvalidPropertyValue(serializationContext, reader, "dslVersion", typeof(global::System.Version), dslVersionStr);
}
catch (global::System.OverflowException)
{
AsyncDslSerializationBehaviorSerializationMessages.InvalidPropertyValue(serializationContext, reader, "dslVersion", typeof(global::System.Version), dslVersionStr);
}
}
}
示例8: ReadPropertiesFromAttributes
protected override void ReadPropertiesFromAttributes(DslModeling::SerializationContext serializationContext, DslModeling::ModelElement element, global::System.Xml.XmlReader reader)
{
base.ReadPropertiesFromAttributes(serializationContext, element, reader);
ClassOperation instanceOfClassOperation = element as ClassOperation;
global::System.Diagnostics.Debug.Assert(instanceOfClassOperation != null, "Expecting an instance of ClassOperation");
// IsAbstract
if (!serializationContext.Result.Failed)
{
string attribIsAbstract = reader.GetAttribute("isAbstract");
if (attribIsAbstract != null)
{
global::System.Boolean valueOfIsAbstract;
if (DslModeling::SerializationUtilities.TryGetValue<global::System.Boolean>(DslModeling::SerializationUtilities.UnescapeXmlString(attribIsAbstract), out valueOfIsAbstract))
{
instanceOfClassOperation.IsAbstract = valueOfIsAbstract;
}
else
{ // Invalid property value, ignored.
FWK_DslSerializationBehaviorSerializationMessages.IgnoredPropertyValue(serializationContext, reader, "isAbstract", typeof(global::System.Boolean), attribIsAbstract);
}
}
}
}
示例9: ReadPropertiesFromAttributes
protected virtual void ReadPropertiesFromAttributes(DslModeling::SerializationContext serializationContext, DslModeling::ModelElement element, global::System.Xml.XmlReader reader)
{
Comment instanceOfComment = element as Comment;
global::System.Diagnostics.Debug.Assert(instanceOfComment != null, "Expecting an instance of Comment");
// Text
if (!serializationContext.Result.Failed)
{
string attribText = reader.GetAttribute("text");
if (attribText != null)
{
global::System.String valueOfText;
if (DslModeling::SerializationUtilities.TryGetValue<global::System.String>(DslModeling::SerializationUtilities.UnescapeXmlString(attribText), out valueOfText))
{
instanceOfComment.Text = valueOfText;
}
else
{ // Invalid property value, ignored.
AsyncDslSerializationBehaviorSerializationMessages.IgnoredPropertyValue(serializationContext, reader, "text", typeof(global::System.String), attribText);
}
}
}
}
示例10: CreateMonikerInstance
/// <summary>
/// This method creates a Moniker of UnidirectionalAssociation based on the tag currently pointed by the reader.
/// </summary>
/// <remarks>
/// The caller will guarantee that the reader is positioned at open XML tag of the next element being read. This method should
/// not move the reader; the reader should remain at the same position when this method returns.
/// </remarks>
/// <param name="serializationContext">Serialization context.</param>
/// <param name="reader">XmlReader to read serialized data from.</param>
/// <param name="sourceRolePlayer">The source role-player instance from which the moniker being created is referenced.</param>
/// <param name="relDomainClassId">The DomainClass Id of the relationship that connects the sourceRolePlayer to the moniker being created.</param>
/// <param name="partition">The new Moniker should be created in the Store associated with this partition.</param>
/// <returns>Created ModelRoot instance, or null if the reader is not pointing to a correct monikerized instance.</returns>
protected override DslModeling::Moniker CreateMonikerInstance (DslModeling::SerializationContext serializationContext, global::System.Xml.XmlReader reader, DslModeling::ModelElement sourceRolePlayer, global::System.Guid relDomainClassId, DslModeling::Partition partition)
{
string monikerString = DslModeling::SerializationUtilities.UnescapeXmlString(reader.GetAttribute(this.MonikerAttributeName));
if (string.IsNullOrEmpty(monikerString))
{
LinqToRdfSerializationBehaviorSerializationMessages.MissingMoniker(serializationContext, reader, this.MonikerAttributeName);
return null;
}
try
{ // Normalize the Id.
global::System.Guid id = new global::System.Guid(monikerString);
monikerString = id.ToString("D", global::System.Globalization.CultureInfo.CurrentCulture);
DslModeling::Moniker result = new DslModeling::Moniker(new DslModeling::MonikerKey(monikerString, relDomainClassId, UnidirectionalAssociation.DomainClassId, partition.Store), partition.Store);
// Set location info if possible.
result.Location = serializationContext.Location;
global::System.Xml.IXmlLineInfo xmlLineInfo = reader as global::System.Xml.IXmlLineInfo;
if (xmlLineInfo != null)
{
result.Line = xmlLineInfo.LineNumber;
result.Column = xmlLineInfo.LinePosition;
}
return result;
}
catch (global::System.FormatException /* fEx */)
{
LinqToRdfSerializationBehaviorSerializationMessages.InvalidPropertyValue(serializationContext, reader, this.MonikerAttributeName, typeof(global::System.Guid), monikerString);
return null;
}
catch (global::System.OverflowException /* oEx */)
{
LinqToRdfSerializationBehaviorSerializationMessages.InvalidPropertyValue(serializationContext, reader, this.MonikerAttributeName, typeof(global::System.Guid), monikerString);
return null;
}
}
示例11: CreateInstance
/// <summary>
/// This method creates an instance of Transition based on the tag currently pointed by the reader. The reader is guaranteed (by the caller)
/// to be pointed at a serialized instance of Transition.
/// </summary>
/// <remarks>
/// The caller will guarantee that the reader is positioned at open XML tag of the ModelRoot instance being read. This method should
/// not move the reader; the reader should remain at the same position when this method returns.
/// </remarks>
/// <param name="serializationContext">Serialization context.</param>
/// <param name="reader">XmlReader to read serialized data from.</param>
/// <param name="partition">Partition in which new Transition instance should be created.</param>
/// <returns>Created Transition instance.</returns>
protected override DslModeling::ModelElement CreateInstance(DslModeling::SerializationContext serializationContext, global::System.Xml.XmlReader reader, DslModeling::Partition partition)
{
string idStr = reader.GetAttribute (StateMachineLanguageSerializationBehavior.Instance.IdSerializationNameDefaultContext);
try
{
global::System.Guid id;
if (string.IsNullOrEmpty(idStr))
{ // Create a default Id.
id = StateMachineLanguageDomainModelIdProvider.Instance.GenerateNewKey();
DslModeling::SerializationUtilities.AddMessage(serializationContext,DslModeling::SerializationMessageKind.Warning,
"Missing 'Id' attribute, a new Guid " + id.ToString() + " is auto-generated. Element type (Transition)",
reader as global::System.Xml.IXmlLineInfo);
//StateMachineLanguageSerializationBehaviorSerializationMessages.MissingId(serializationContext, reader, id);
}
else
{
id = StateMachineLanguageSerializationHelper.Instance.ConvertIdFrom(serializationContext, idStr);
}
// Create the link with place-holder role-players.
return new global::Tum.StateMachineDSL.Transition(
partition,
new DslModeling::RoleAssignment[] {
DslModeling::RoleAssignment.CreatePlaceholderRoleAssignment (global::Tum.StateMachineDSL.Transition.StateBaseSourceDomainRoleId),
DslModeling::RoleAssignment.CreatePlaceholderRoleAssignment (global::Tum.StateMachineDSL.Transition.StateBaseTargetDomainRoleId)
},
new DslModeling::PropertyAssignment[] {
new DslModeling::PropertyAssignment(DslModeling::ElementFactory.IdPropertyAssignment, id)
}
);
}
catch (global::System.ArgumentNullException /* anEx */)
{
StateMachineLanguageSerializationBehaviorSerializationMessages.InvalidPropertyValue(serializationContext, reader, "Id", typeof(global::System.Guid), idStr);
}
catch (global::System.FormatException /* fEx */)
{
StateMachineLanguageSerializationBehaviorSerializationMessages.InvalidPropertyValue(serializationContext, reader, "Id", typeof(global::System.Guid), idStr);
}
catch (global::System.OverflowException /* ofEx */)
{
StateMachineLanguageSerializationBehaviorSerializationMessages.InvalidPropertyValue(serializationContext, reader, "Id", typeof(global::System.Guid), idStr);
}
return null;
}
示例12: CreateInstance
/// <summary>
/// This method creates an instance of Test based on the tag currently pointed by the reader. The reader is guaranteed (by the caller)
/// to be pointed at a serialized instance of Test.
/// </summary>
/// <remarks>
/// The caller will guarantee that the reader is positioned at open XML tag of the ModelRoot instance being read. This method should
/// not move the reader; the reader should remain at the same position when this method returns.
/// </remarks>
/// <param name="serializationContext">Serialization context.</param>
/// <param name="reader">XmlReader to read serialized data from.</param>
/// <param name="partition">Partition in which new Test instance should be created.</param>
/// <returns>Created Test instance.</returns>
protected override DslModeling::ModelElement CreateInstance(DslModeling::SerializationContext serializationContext, global::System.Xml.XmlReader reader, DslModeling::Partition partition)
{
string idStr = reader.GetAttribute (TestLanguageSerializationBehavior.Instance.IdSerializationNameDefaultContext);
try
{
global::System.Guid id;
if (string.IsNullOrEmpty(idStr))
{ // Create a default Id.
id = TestLanguageDomainModelIdProvider.Instance.GenerateNewKey();
DslModeling::SerializationUtilities.AddMessage(serializationContext,DslModeling::SerializationMessageKind.Warning,
"Missing 'Id' attribute, a new Guid " + id.ToString() + " is auto-generated. Element type (Test)",
reader as global::System.Xml.IXmlLineInfo);
//TestLanguageSerializationBehaviorSerializationMessages.MissingId(serializationContext, reader, id);
}
else
{
id = TestLanguageSerializationHelper.Instance.ConvertIdFrom(serializationContext, idStr);
}
return new global::Tum.TestLanguage.Test(partition, new DslModeling::PropertyAssignment(DslModeling::ElementFactory.IdPropertyAssignment, id));
}
catch (global::System.ArgumentNullException /* anEx */)
{
TestLanguageSerializationBehaviorSerializationMessages.InvalidPropertyValue(serializationContext, reader, "Id", typeof(global::System.Guid), idStr);
}
catch (global::System.FormatException /* fEx */)
{
TestLanguageSerializationBehaviorSerializationMessages.InvalidPropertyValue(serializationContext, reader, "Id", typeof(global::System.Guid), idStr);
}
catch (global::System.OverflowException /* ofEx */)
{
TestLanguageSerializationBehaviorSerializationMessages.InvalidPropertyValue(serializationContext, reader, "Id", typeof(global::System.Guid), idStr);
}
return null;
}
示例13: CreateInstance
/// <summary>
/// This method creates an instance of ManyToOneRelation based on the tag currently pointed by the reader. The reader is guaranteed (by the caller)
/// to be pointed at a serialized instance of ManyToOneRelation.
/// </summary>
/// <remarks>
/// The caller will guarantee that the reader is positioned at open XML tag of the ModelRoot instance being read. This method should
/// not move the reader; the reader should remain at the same position when this method returns.
/// </remarks>
/// <param name="serializationContext">Serialization context.</param>
/// <param name="reader">XmlReader to read serialized data from.</param>
/// <param name="partition">Partition in which new ManyToOneRelation instance should be created.</param>
/// <returns>Created ManyToOneRelation instance.</returns>
protected override DslModeling::ModelElement CreateInstance(DslModeling::SerializationContext serializationContext, global::System.Xml.XmlReader reader, DslModeling::Partition partition)
{
string idStr = reader.GetAttribute ("Id");
try
{
global::System.Guid id;
if (string.IsNullOrEmpty(idStr))
{ // Create a default Id.
id = global::System.Guid.NewGuid();
ActiveWriterSerializationBehaviorSerializationMessages.MissingId(serializationContext, reader, id);
}
else
{
id = new global::System.Guid (idStr);
}
// Create the link with place-holder role-players.
return new ManyToOneRelation(
partition,
new DslModeling::RoleAssignment[] {
DslModeling::RoleAssignment.CreatePlaceholderRoleAssignment (ManyToOneRelation.SourceDomainRoleId),
DslModeling::RoleAssignment.CreatePlaceholderRoleAssignment (ManyToOneRelation.TargetDomainRoleId)
},
new DslModeling::PropertyAssignment[] {
new DslModeling::PropertyAssignment(DslModeling::ElementFactory.IdPropertyAssignment, id)
}
);
}
catch (global::System.ArgumentNullException /* anEx */)
{
ActiveWriterSerializationBehaviorSerializationMessages.InvalidPropertyValue(serializationContext, reader, "Id", typeof(global::System.Guid), idStr);
}
catch (global::System.FormatException /* fEx */)
{
ActiveWriterSerializationBehaviorSerializationMessages.InvalidPropertyValue(serializationContext, reader, "Id", typeof(global::System.Guid), idStr);
}
catch (global::System.OverflowException /* ofEx */)
{
ActiveWriterSerializationBehaviorSerializationMessages.InvalidPropertyValue(serializationContext, reader, "Id", typeof(global::System.Guid), idStr);
}
return null;
}
示例14: ReadAttribute
/// <summary>
/// Reads and returns the value of an attribute.
/// </summary>
/// <param name="serializationContext">The current serialization context instance.</param>
/// <param name="element">The element whose attributes have just been written.</param>
/// <param name="reader">XmlReader to read the serialized data from.</param>
/// <param name="attributeName">The name of the attribute to be read.</param>
/// <returns>The value of the attribute.</returns>
/// <remarks>This is an extension point to allow customisation e.g. to decode the data
/// being written to the file.</remarks>
public virtual string ReadAttribute(DslModeling::SerializationContext serializationContext, DslModeling::ModelElement element, global::System.Xml.XmlReader reader, string attributeName)
{
return reader.GetAttribute(attributeName);
}