×¢²á
Íü¼ÇÃÜÂë
̞
ÃÜÂë
¼ÓÈëÊÕ²Ø
Éè²Æ¹ÉÍøΪÊ×Ò³
ÍøÕ¾µØͼ
²Æ¹ÉÍøµ¼º½
ÉÌÎñºÏ×÷
²Æ¾
¹ÉƱ
×ÊѶ×ÛºÏÃÅ»§
²Æ¹ÉÍø
(Caiguu.com)ÊÇ
Öйú²Æ¾¹ÉƱ×ÊѶ×ÛºÏÃÅ»§
,ΪÄúÌṩº¸Ç
¹ÉƱ
¡¢
²Æ¾
¡¢
Àí²Æ
¡¢A¹É¡¢
¸Û¹É
¡¢
Êг¡
¡¢
´óÅÌ
¡¢
Ö÷Á¦
¡¢
ÐÐÒµ
µÈ²Æ¾¹ÉƱÁìÓò×ÊѶ¡£²¢ÒÔ¹ÉƱΪרע,Ìṩ
¹ÉƱÐÐÇé
¡¢
¹ÉƱ²éѯ
¡¢
¹ÉƱ·ÖÎö
¡¢
¹ÉƱ֪ʶ
¡¢
¹ÉƱͶ×Ê
µÈ×ÛºÏÐÔ·þÎñ¡£
ÖصãÍƼöÀ¸Ä¿£º
½ñÈÕ¹ÉƱÐÐÇé
¡¢
¹ÉƱÈëÃÅ»ù´¡ÖªÊ¶
¡¢
Ãâ·ÑÍƼö¹ÉƱ
¡¢
¸ö¹É
¡¢
Àí²Æ¹¤¾ß
¡£
¹ÉƱ
Êг¡
¸ö¹É
Ö÷Á¦
ÐÐÒµ
йÉ
¹«Ë¾
»ú¹¹
°å¿é
ѧԺ
´óÅÌ
¾Û½¹
Ìáʾ
ÊÓµã
Êý¾Ý
½»Ò×
¾«»ª
²âÆÀ
Ñо¿
DZ¹É
ÒªÎÅ
¹ÉÖ¸
Ȩ֤
B¹É
Èý°å
ÁìÕÇ
´´Òµ°å
ÖÐС°å
¸Û¹É
È«Çò
²Æ¾
ÐÂÎÅ
¹úÄÚ
¹úÍâ
ºê¹Û
×ʱ¾
ÉÌÒµ
²úÒµ
ÆÀÂÛ
ר¼Ò
¹Û²ì
½²ÌÃ
Àí²Æ
»Æ½ð
Íâ»ã
ծȯ
»ù½ð
ÒøÐÐ
±£ÏÕ
ÐÅÍÐ
×ÛºÏ
²Æ¹É
ÏûÏ¢
¼¼ÇÉ
Ê×Ò³
ÈÈÃÅרÀ¸£º
¸»°Ö°ÖÇî°Ö°Ö
¹ÉƱÈí¼þ
¸ÅÄî¹É
¹ÉƱ¹ÀÖµ
p.ParameterType + " " + p.ParameterName).ToArray()))); this.Write(")\r\n {\r\n "); this.Write(this.ToStringHelper.ToStringWithCulture(code.Escape(structuralType))); this.Write(" "); this.Write(this.ToStringHelper.ToStringWithCulture(instanceName)); this.Write(" = new "); this.Write(this.ToStringHelper.ToStringWithCulture(code.Escape(structuralType))); this.Write("();\r\n"); foreach (FactoryMethodParameter parameter in parameters) { if (parameter.IsComplexType) { // this.Write(" "); this.Write(this.ToStringHelper.ToStringWithCulture(instanceName)); this.Write("."); this.Write(this.ToStringHelper.ToStringWithCulture(code.Escape(parameter.Source))); this.Write(" = StructuralObject.VerifyComplexObjectIsNotNull("); this.Write(this.ToStringHelper.ToStringWithCulture(parameter.ParameterName)); this.Write(", \""); this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Source.Name)); this.Write("\");\r\n"); } else { // this.Write(" "); this.Write(this.ToStringHelper.ToStringWithCulture(instanceName)); this.Write("."); this.Write(this.ToStringHelper.ToStringWithCulture(code.Escape(parameter.Source))); this.Write(" = "); this.Write(this.ToStringHelper.ToStringWithCulture(parameter.ParameterName)); this.Write(";\r\n"); } } this.Write(" return "); this.Write(this.ToStringHelper.ToStringWithCulture(instanceName)); this.Write(";\r\n }\r\n"); region.End(); } //////// //////// //////// private void WriteSimpleTypeProperty(EdmProperty simpleProperty, CodeGenerationTools code) { MetadataTools ef = new MetadataTools(this); this.Write("\r\n ///
\r\n /// "); this.Write(this.ToStringHelper.ToStringWithCulture(SummaryComment(simpleProperty))); this.Write("\r\n ///
"); this.Write(this.ToStringHelper.ToStringWithCulture(LongDescriptionCommentElement(simpleProperty, 1))); this.Write("\r\n [EdmScalarPropertyAttribute(EntityKeyProperty="); this.Write(this.ToStringHelper.ToStringWithCulture(code.CreateLiteral(ef.IsKey(simpleProperty)))); this.Write(", IsNullable="); this.Write(this.ToStringHelper.ToStringWithCulture(code.CreateLiteral(ef.IsNullable(simpleProperty)))); this.Write(")]\r\n [DataMemberAttribute()]\r\n "); this.Write(this.ToStringHelper.ToStringWithCulture(code.SpaceAfter(NewModifier(simpleProperty)))); this.Write(this.ToStringHelper.ToStringWithCulture(Accessibility.ForProperty(simpleProperty))); this.Write(" "); this.Write(this.ToStringHelper.ToStringWithCulture(MultiSchemaEscape(simpleProperty.TypeUsage, code))); this.Write(" "); this.Write(this.ToStringHelper.ToStringWithCulture(code.Escape(simpleProperty))); this.Write("\r\n {\r\n "); this.Write(this.ToStringHelper.ToStringWithCulture(code.SpaceAfter(Accessibility.ForGetter(simpleProperty)))); this.Write("get\r\n {\r\n"); if (ef.ClrType(simpleProperty.TypeUsage) == typeof(byte[])) { this.Write(" return StructuralObject.GetValidValue("); this.Write(this.ToStringHelper.ToStringWithCulture(code.FieldName(simpleProperty))); this.Write(");\r\n"); } else { this.Write(" return "); this.Write(this.ToStringHelper.ToStringWithCulture(code.FieldName(simpleProperty))); this.Write(";\r\n"); } this.Write(" }\r\n "); this.Write(this.ToStringHelper.ToStringWithCulture(code.SpaceAfter(Accessibility.ForSetter((simpleProperty))))); this.Write("set\r\n {\r\n"); if (ef.IsKey(simpleProperty)) { if (ef.ClrType(simpleProperty.TypeUsage) == typeof(byte[])) { this.Write(" if (!StructuralObject.BinaryEquals("); this.Write(this.ToStringHelper.ToStringWithCulture(code.FieldName(simpleProperty))); this.Write(", value))\r\n"); } else { this.Write(" if ("); this.Write(this.ToStringHelper.ToStringWithCulture(code.FieldName(simpleProperty))); this.Write(" != value)\r\n"); } this.Write(" {\r\n"); PushIndent(CodeRegion.GetIndent(1)); } this.Write(" "); this.Write(this.ToStringHelper.ToStringWithCulture(ChangingMethodName(simpleProperty))); this.Write("(value);\r\n ReportPropertyChanging(\""); this.Write(this.ToStringHelper.ToStringWithCulture(simpleProperty.Name)); this.Write("\");\r\n "); this.Write(this.ToStringHelper.ToStringWithCulture(code.FieldName(simpleProperty))); this.Write(" = "); this.Write(this.ToStringHelper.ToStringWithCulture(CastToEnumType(simpleProperty.TypeUsage, code))); this.Write("StructuralObject.SetValidValue("); this.Write(this.ToStringHelper.ToStringWithCulture(CastToUnderlyingType(simpleProperty.TypeUsage, code))); this.Write("value"); this.Write(this.ToStringHelper.ToStringWithCulture(OptionalNullableParameterForSetValidValue(simpleProperty, code))); this.Write(", \""); this.Write(this.ToStringHelper.ToStringWithCulture(simpleProperty.Name)); this.Write("\");\r\n ReportPropertyChanged(\""); this.Write(this.ToStringHelper.ToStringWithCulture(simpleProperty.Name)); this.Write("\");\r\n "); this.Write(this.ToStringHelper.ToStringWithCulture(ChangedMethodName(simpleProperty))); this.Write("();\r\n"); if (ef.IsKey(simpleProperty)) { PopIndent(); this.Write(" }\r\n"); } this.Write(" }\r\n }\r\n private "); this.Write(this.ToStringHelper.ToStringWithCulture(MultiSchemaEscape(simpleProperty.TypeUsage, code))); this.Write(" "); this.Write(this.ToStringHelper.ToStringWithCulture(code.FieldName(simpleProperty))); this.Write(this.ToStringHelper.ToStringWithCulture(code.StringBefore(" = ", code.CreateLiteral(simpleProperty.DefaultValue)))); this.Write(";\r\n partial void "); this.Write(this.ToStringHelper.ToStringWithCulture(ChangingMethodName(simpleProperty))); this.Write("("); this.Write(this.ToStringHelper.ToStringWithCulture(MultiSchemaEscape(simpleProperty.TypeUsage, code))); this.Write(" value);\r\n partial void "); this.Write(this.ToStringHelper.ToStringWithCulture(ChangedMethodName(simpleProperty))); this.Write("();\r\n"); } //////// //////// //////// private void WriteComplexTypeProperty(EdmProperty complexProperty, CodeGenerationTools code) { this.Write("\r\n ///
\r\n /// "); this.Write(this.ToStringHelper.ToStringWithCulture(SummaryComment(complexProperty))); this.Write("\r\n ///
"); this.Write(this.ToStringHelper.ToStringWithCulture(LongDescriptionCommentElement(complexProperty, 1))); this.Write("\r\n [EdmComplexPropertyAttribute()]\r\n [DesignerSerializationVisibility(Desig" + "nerSerializationVisibility.Content)]\r\n [XmlElement(IsNullable=true)]\r\n [So" + "apElement(IsNullable=true)]\r\n [DataMemberAttribute()]\r\n "); this.Write(this.ToStringHelper.ToStringWithCulture(code.SpaceAfter(NewModifier(complexProperty)))); this.Write(this.ToStringHelper.ToStringWithCulture(Accessibility.ForProperty(complexProperty))); this.Write(" "); this.Write(this.ToStringHelper.ToStringWithCulture(MultiSchemaEscape(complexProperty.TypeUsage, code))); this.Write(" "); this.Write(this.ToStringHelper.ToStringWithCulture(code.Escape(complexProperty))); this.Write("\r\n {\r\n "); this.Write(this.ToStringHelper.ToStringWithCulture(code.SpaceAfter(Accessibility.ForGetter(complexProperty)))); this.Write("get\r\n {\r\n "); this.Write(this.ToStringHelper.ToStringWithCulture(code.FieldName(complexProperty))); this.Write(" = GetValidValue("); this.Write(this.ToStringHelper.ToStringWithCulture(code.FieldName(complexProperty))); this.Write(", \""); this.Write(this.ToStringHelper.ToStringWithCulture(complexProperty.Name)); this.Write("\", false, "); this.Write(this.ToStringHelper.ToStringWithCulture(InitializedTrackingField(complexProperty, code))); this.Write(");\r\n "); this.Write(this.ToStringHelper.ToStringWithCulture(InitializedTrackingField(complexProperty, code))); this.Write(" = true;\r\n return "); this.Write(this.ToStringHelper.ToStringWithCulture(code.FieldName(complexProperty))); this.Write(";\r\n }\r\n "); this.Write(this.ToStringHelper.ToStringWithCulture(code.SpaceAfter(Accessibility.ForSetter(complexProperty)))); this.Write("set\r\n {\r\n "); this.Write(this.ToStringHelper.ToStringWithCulture(ChangingMethodName(complexProperty))); this.Write("(value);\r\n ReportPropertyChanging(\""); this.Write(this.ToStringHelper.ToStringWithCulture(complexProperty.Name)); this.Write("\");\r\n "); this.Write(this.ToStringHelper.ToStringWithCulture(code.FieldName(complexProperty))); this.Write(" = SetValidValue("); this.Write(this.ToStringHelper.ToStringWithCulture(code.FieldName(complexProperty))); this.Write(", value, \""); this.Write(this.ToStringHelper.ToStringWithCulture(complexProperty.Name)); this.Write("\");\r\n "); this.Write(this.ToStringHelper.ToStringWithCulture(InitializedTrackingField(complexProperty, code))); this.Write(" = true;\r\n ReportPropertyChanged(\""); this.Write(this.ToStringHelper.ToStringWithCulture(complexProperty.Name)); this.Write("\");\r\n "); this.Write(this.ToStringHelper.ToStringWithCulture(ChangedMethodName(complexProperty))); this.Write("();\r\n }\r\n }\r\n private "); this.Write(this.ToStringHelper.ToStringWithCulture(MultiSchemaEscape(complexProperty.TypeUsage, code))); this.Write(" "); this.Write(this.ToStringHelper.ToStringWithCulture(code.FieldName(complexProperty))); this.Write(";\r\n private bool "); this.Write(this.ToStringHelper.ToStringWithCulture(InitializedTrackingField(complexProperty, code))); this.Write(";\r\n partial void "); this.Write(this.ToStringHelper.ToStringWithCulture(ChangingMethodName(complexProperty))); this.Write("("); this.Write(this.ToStringHelper.ToStringWithCulture(MultiSchemaEscape(complexProperty.TypeUsage, code))); this.Write(" value);\r\n partial void "); this.Write(this.ToStringHelper.ToStringWithCulture(ChangedMethodName(complexProperty))); this.Write("();\r\n"); } private void WriteFunctionParameters(IEnumerable
parameters) { foreach (FunctionImportParameter parameter in parameters) { if (!parameter.NeedsLocalVariable) { continue; } this.Write(" ObjectParameter "); this.Write(this.ToStringHelper.ToStringWithCulture(parameter.LocalVariableName)); this.Write(";\r\n if ("); this.Write(this.ToStringHelper.ToStringWithCulture(parameter.IsNullableOfT ? parameter.FunctionParameterName + ".HasValue" : parameter.FunctionParameterName + " != null")); this.Write(")\r\n {\r\n "); this.Write(this.ToStringHelper.ToStringWithCulture(parameter.LocalVariableName)); this.Write(" = new ObjectParameter(\""); this.Write(this.ToStringHelper.ToStringWithCulture(parameter.EsqlParameterName)); this.Write("\", "); this.Write(this.ToStringHelper.ToStringWithCulture(parameter.FunctionParameterName)); this.Write(");\r\n }\r\n else\r\n {\r\n "); this.Write(this.ToStringHelper.ToStringWithCulture(parameter.LocalVariableName)); this.Write(" = new ObjectParameter(\""); this.Write(this.ToStringHelper.ToStringWithCulture(parameter.EsqlParameterName)); this.Write("\", typeof("); this.Write(this.ToStringHelper.ToStringWithCulture(parameter.RawClrTypeName)); this.Write("));\r\n }\r\n\r\n"); } } private void WriteLazyLoadingEnabled(EntityContainer container) { string lazyLoadingAttributeValue = null; string lazyLoadingAttributeName = MetadataConstants.EDM_ANNOTATION_09_02 + ":LazyLoadingEnabled"; if(MetadataTools.TryGetStringMetadataPropertySetting(container, lazyLoadingAttributeName, out lazyLoadingAttributeValue)) { bool isLazyLoading = false; if(bool.TryParse(lazyLoadingAttributeValue, out isLazyLoading)) { this.Write(" this.ContextOptions.LazyLoadingEnabled = "); this.Write(this.ToStringHelper.ToStringWithCulture(isLazyLoading.ToString().ToLowerInvariant())); this.Write(";\r\n"); } } } //////// //////// //////// public string SourceCsdlPath{ get; set; } public string ModelNamespace{ get; set; } public EdmItemCollection ItemCollection{ get; set; } public IEnumerable
ReferenceCsdlPaths{ get; set; } public Nullable
CreateContextAddToMethods{ get; set; } public Dictionary
EdmToObjectNamespaceMap { get { return _edmToObjectNamespaceMap; } set { _edmToObjectNamespaceMap = value; } } public Dictionary
_edmToObjectNamespaceMap = new Dictionary
(); public Double SourceEdmVersion { get { if (ItemCollection != null) { return ItemCollection.EdmVersion; } return 0.0; } } private bo~?? € €ol VerifyTypeUniqueness(IEnumerable
types) { HashSet
hash = new HashSet
(); foreach (string type in types) { if (!hash.Add(type)) { // Errors.Add(new System.CodeDom.Compiler.CompilerError(SourceCsdlPath, -1, -1, "6034", String.Format(CultureInfo.CurrentCulture, CodeGenerationTools.GetResourceString("Template_DuplicateTopLevelType"), type))); return false; } } return true; } void ApplyUserSettings(UserSettings userSettings) { // if (SourceCsdlPath == null) { #if !PREPROCESSED_TEMPLATE if(userSettings.SourceCsdlPath == "$" + "edmxInputFile" + "$") { Errors.Add(new System.CodeDom.Compiler.CompilerError(Host.TemplateFile, -1, -1, "", CodeGenerationTools.GetResourceString("Template_ReplaceVsItemTemplateToken"))); return; } SourceCsdlPath = Host.ResolvePath(userSettings.SourceCsdlPath); #else SourceCsdlPath = userSettings.SourceCsdlPath; #endif } // normalize the path, remove ..\ from it SourceCsdlPath = Path.GetFullPath(SourceCsdlPath); if (ReferenceCsdlPaths == null) { ReferenceCsdlPaths = userSettings.ReferenceCsdlPaths; } if (!CreateContextAddToMethods.HasValue) { CreateContextAddToMethods = userSettings.CreateContextAddToMethods; } DefaultSummaryComment = CodeGenerationTools.GetResourceString("Template_CommentNoDocumentation"); } class UserSettings { public string SourceCsdlPath{ get; set; } public string[] ReferenceCsdlPaths{ get; set; } public bool FullyQualifySystemTypes{ get; set; } public bool CreateContextAddToMethods{ get; set; } public bool CamelCaseFields{ get; set; } } string GetNamespaceName(CodeGenerationTools code) { string namespaceName = code.VsNamespaceSuggestion(); #if PREPROCESSED_TEMPLATE if (String.IsNullOrEmpty(namespaceName)) me', function factory(injectables) { * var directiveDefinitionObject = { * priority: 0, * template: '
', // or // function(tElement, tAttrs) { ... }, * // or * // templateUrl: 'directive.html', // or // function(tElement, tAttrs) { ... }, * transclude: false, * restrict: 'A', * templateNamespace: 'html', * scope: false, * controller: function($scope, $element, $attrs, $transclude, otherInjectables) { ... }, * controllerAs: 'stringIdentifier', * bindToController: false, * require: 'siblingDirectiveName', // or // ['^parentDirectiveName', '?optionalDirectiveName', '?^optionalParent'], * compile: function compile(tElement, tAttrs, transclude) { * return { * pre: function preLink(scope, iElement, iAttrs, controller) { ... }, * post: function postLink(scope, iElem