当前位置: 首页>>代码示例>>C#>>正文


C# SaveOptions类代码示例

本文整理汇总了C#中SaveOptions的典型用法代码示例。如果您正苦于以下问题:C# SaveOptions类的具体用法?C# SaveOptions怎么用?C# SaveOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SaveOptions类属于命名空间,在下文中一共展示了SaveOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SaveXElement

 private string SaveXElement(object elem, SaveOptions so)
 {
     string retVal = null;
     switch (_mode)
     {
         case "Save":
             using (StringWriter sw = new StringWriter())
             {
                 if (_type.Name == "XElement")
                 {
                     (elem as XElement).Save(sw, so);
                 }
                 else if (_type.Name == "XDocument")
                 {
                     (elem as XDocument).Save(sw, so);
                 }
                 retVal = sw.ToString();
             }
             break;
         case "ToString":
             if (_type.Name == "XElement")
             {
                 retVal = (elem as XElement).ToString(so);
             }
             else if (_type.Name == "XDocument")
             {
                 retVal = (elem as XDocument).ToString(so);
             }
             break;
         default:
             TestLog.Compare(false, "TEST FAILED: wrong mode");
             break;
     }
     return retVal;
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:35,代码来源:SaveOptions_OmitDuplicateNamespace.cs

示例2: SaveChanges

		public override int SaveChanges(SaveOptions options)
		{
			BeforeSaveChanges(this);
			var result = base.SaveChanges(options);
			AfterSaveChanges(this);
			return result;
		}
开发者ID:RareNCool,项目名称:MyToolkit,代码行数:7,代码来源:ExtendedDataContext.cs

示例3: Tidy

 ///<summary>
 /// Tidies the XML file by formatting it in alphabetical order.
 ///</summary>
 ///<param name="inputXml"></param>
 ///<param name="saveOptions">Allows choosing between formatted/non-formatter output</param>
 ///<returns></returns>
 public string Tidy(string inputXml, SaveOptions saveOptions)
 {
     var xmlDoc = XDocument.Parse(inputXml,LoadOptions.PreserveWhitespace);
     var first = xmlDoc.Elements().First();
     first.ReplaceWith(GetOrderedElement(first));
     return xmlDoc.Declaration + xmlDoc.ToString(saveOptions);
 }
开发者ID:latish,项目名称:FormatAppSettings,代码行数:13,代码来源:AppSettingsFormatter.cs

示例4: CustomResourcesProcessing

        // ExStart:PrefixForFontsHelper
        private static string CustomResourcesProcessing(SaveOptions.ResourceSavingInfo resourceSavingInfo)
        {
            //-----------------------------------------------------------------------------
            // It's just example of possible realization of cusstom processing of resources
            // Referenced in result HTML
            //-----------------------------------------------------------------------------

            // 1) In this case we need only do something special
            //    with fonts, so let's leave processing of all other resources
            //    to converter itself
            if (resourceSavingInfo.ResourceType != SaveOptions.NodeLevelResourceType.Font)
            {
                resourceSavingInfo.CustomProcessingCancelled = true;
                return "";
            }

            // If supplied font resource, process it ourselves
            // 1) Write supplied font with short name  to desired folder
            //    You can easily do anythings  - it's just one of realizations

            _fontNumberForUniqueFontFileNames++;
            string shortFontFileName = (_fontNumberForUniqueFontFileNames.ToString() + Path.GetExtension(resourceSavingInfo.SupposedFileName));
            string outFontPath = _desiredFontDir + "\\" + shortFontFileName;

            System.IO.BinaryReader fontBinaryReader = new BinaryReader(resourceSavingInfo.ContentStream);
            System.IO.File.WriteAllBytes(outFontPath, fontBinaryReader.ReadBytes((int)resourceSavingInfo.ContentStream.Length));


            // 2) Return the desired URI with which font will be referenced in CSSes
            string fontUrl = "http:// Localhost:255/document-viewer/GetFont/" + shortFontFileName;
            return fontUrl;
        }
开发者ID:aspose-pdf,项目名称:Aspose.Pdf-for-.NET,代码行数:33,代码来源:PrefixForFonts.cs

示例5: SaveChanges

        public override int SaveChanges(SaveOptions options)
        {
            foreach (ObjectStateEntry entry in
                ObjectStateManager.GetObjectStateEntries(
                EntityState.Added | EntityState.Modified))
            {
                if (entry.Entity is Configuration)
                {
                    ValidateConfigurationAggregate((Configuration)entry.Entity);
                }
                else if (entry.Entity is Payment)
                {

                    ValidatePaymentAggregate((Payment)entry.Entity);

                    if (entry.State == EntityState.Added)
                    {
                        Payment payment = (Payment)entry.Entity;
                        payment.PaymentCode = PaymentCode.NextPaymentCode(this);
                    }
                }
            }

            return base.SaveChanges(options);
        }
开发者ID:anupong-s,项目名称:Transaction,代码行数:25,代码来源:TransactionModelContainer.cs

示例6: CustomSaveOfFontsAndImages

        private static string CustomSaveOfFontsAndImages(SaveOptions.ResourceSavingInfo resourceSavingInfo)
        {
            System.IO.BinaryReader reader = new BinaryReader(resourceSavingInfo.ContentStream);
            byte[] resourceAsBytes = reader.ReadBytes((int)resourceSavingInfo.ContentStream.Length);

            if (resourceSavingInfo.ResourceType == SaveOptions.NodeLevelResourceType.Font)
            {
                Console.WriteLine("Font processed with handler. Length of content in bytes is " + resourceAsBytes.Length.ToString());
                // Here You can put code that will save font to some storage, f.e database
                MemoryStream targetStream = new MemoryStream();
                targetStream.Write(resourceAsBytes, 0, resourceAsBytes.Length);
            }
            else if (resourceSavingInfo.ResourceType == SaveOptions.NodeLevelResourceType.Image)
            {
                Console.WriteLine("Image processed with handler. Length of content in bytes is " + resourceAsBytes.Length.ToString());
                // Here You can put code that will save image to some storage, f.e database
                MemoryStream targetStream = new MemoryStream();
                targetStream.Write(resourceAsBytes, 0, resourceAsBytes.Length);
            }

            // We should return URI bt which resource will be referenced in CSS(for font)
            // Or HTML(for images)
            //  This  is very siplistic way - here we just return file name or resource.
            //  You can put here some URI that will include ID of resource in database etc. 
            //  - this URI will be added into result CSS or HTML to refer the resource
            return resourceSavingInfo.SupposedFileName;
        }
开发者ID:aspose-pdf,项目名称:Aspose.Pdf-for-.NET,代码行数:27,代码来源:SaveHTMLImageCSS.cs

示例7: SaveChanges

 public override int SaveChanges(SaveOptions options)
 {
     int returnValue = 0;
     // 因为我们不调用base.SaveChanges, 我们必须手动关闭链接.
     // 否则我们将留下许多打开的链接, 最终导致链接瓶颈.
     // Entity Framework提供了base.SaveChanges内部使用的EnsureConnection和ReleaseConnection.
     // 这些是内部方法, 所以我们必须使用反射调用它们.
     var EnsureConnectionMethod = typeof(ObjectContext).GetMethod(
         "EnsureConnection", BindingFlags.Instance | BindingFlags.NonPublic);
     EnsureConnectionMethod.Invoke(this, null);
     // 使用ObjectStateManager.GetObjectStateEntries完成增加,修改,和删除集合.
     foreach (ObjectStateEntry ose in this.ObjectStateManager.GetObjectStateEntries(EntityState.Added))
     {
         Travel travel = ose.Entity as Travel;
         if (travel != null)
         {
             RetryPolicy retryPolicy = new RetryPolicy();
             retryPolicy.Task = new Action(() =>
             {
                 this.InsertIntoTravel(travel.PartitionKey,
                     travel.Place, travel.GeoLocationText, travel.Time);
             });
             retryPolicy.Execute();
             returnValue++;
         }
     }
     foreach (ObjectStateEntry ose in this.ObjectStateManager.GetObjectStateEntries(EntityState.Modified))
     {
         Travel travel = ose.Entity as Travel;
         if (travel != null)
         {
             RetryPolicy retryPolicy = new RetryPolicy();
             retryPolicy.Task = new Action(() =>
             {
                 this.UpdateTravel(travel.PartitionKey,
                     travel.RowKey, travel.Place, travel.GeoLocationText, travel.Time);
             });
             retryPolicy.Execute();
             returnValue++;
         }
     }
     foreach (ObjectStateEntry ose in this.ObjectStateManager.GetObjectStateEntries(EntityState.Deleted))
     {
         Travel travel = ose.Entity as Travel;
         if (travel != null)
         {
             RetryPolicy retryPolicy = new RetryPolicy();
             retryPolicy.Task = new Action(() =>
             {
                 this.DeleteFromTravel(travel.PartitionKey, travel.RowKey);
             });
             retryPolicy.Execute();
             returnValue++;
         }
     }
     var ReleaseConnectionMethod = typeof(ObjectContext).
         GetMethod("ReleaseConnection", BindingFlags.Instance | BindingFlags.NonPublic);
     ReleaseConnectionMethod.Invoke(this, null);
     return returnValue;
 }
开发者ID:zealoussnow,项目名称:OneCode,代码行数:60,代码来源:TravelModelContainer.cs

示例8: SaveChanges

		public override int SaveChanges(SaveOptions options) {
			foreach(ObjectStateEntry objectStateEntry in ObjectStateManager.GetObjectStateEntries(EntityState.Added)) {
				if(objectStateEntry.Entity is Event) {
					((Event)objectStateEntry.Entity).BeforeSave();
				}
			}
			return base.SaveChanges(options);
		}
开发者ID:kamchung322,项目名称:eXpand,代码行数:8,代码来源:EFDemoObjectContext.cs

示例9: SaveChanges

 public void SaveChanges(SaveOptions saveOptions)
 {
     if (IsInTransaction)
     {
         throw new ApplicationException("A transaction is currently open. Use RollBackTransaction or CommitTransaction instead.");
     }
     ((IObjectContextAdapter)_dbContext).ObjectContext.SaveChanges(saveOptions);
 }
开发者ID:ricardo100671,项目名称:Avantech.Common,代码行数:8,代码来源:EFUnitOfWork.cs

示例10: ToXml

		/// <summary>
		///   Преобразовать документ в XML-строку
		/// </summary>
		/// <param name="document"> Документ </param>
		/// <param name="encoding"> Кодировка документа </param>
		/// <param name="options"> Опции сохранения </param>
		/// <returns> </returns>
		public static string ToXml(this XDocument document, Encoding encoding, SaveOptions options)
		{
			using (var writer = new EncodedStringWriter(encoding))
			{
				document.Save(writer, options);
				return writer.ToString();
			}
		}
开发者ID:v0id24,项目名称:ByndyuSoft.Infrastructure,代码行数:15,代码来源:XDocumentExtensions.cs

示例11: SaveChanges

        public int SaveChanges(SaveOptions options, bool logChanges)
        {
            int result = base.SaveChanges(options);

            if(SavedChanges != null)
                SavedChanges(this, null);

            return result;
        }
开发者ID:markusl,项目名称:jro,代码行数:9,代码来源:MembersContainer.cs

示例12: SaveChanges

        public override int SaveChanges(SaveOptions options)
        {
            int result = base.SaveChanges(options);

            if (SavedChanges != null)
                SavedChanges(this, new EventArgs());

            return result;
        }
开发者ID:vc3,项目名称:ExoModel,代码行数:9,代码来源:ModelObjectContext.cs

示例13: SaveChanges

    public void SaveChanges(SaveOptions saveOptions)
    {
      if (IsInTransaction)
      {
        throw new ApplicationException("A transaction is running. Call CommitTransaction instead.");
      }

      ((IObjectContextAdapter)_dbContext).ObjectContext.SaveChanges(saveOptions);
    }
开发者ID:Double222,项目名称:Samurai,代码行数:9,代码来源:UnitOfWork.cs

示例14: SaveChanges

 public override int SaveChanges(SaveOptions options)
 {
     var changes = ObjectStateManager.GetObjectStateEntries(EntityState.Unchanged);
     foreach (var change in changes)
     {
         var entityWithId = change.Entity as EntityWithId;
         if (entityWithId != null)
             ChangeStateOfEntity(ObjectStateManager, entityWithId);
     }
     return base.SaveChanges(options);
 }
开发者ID:felixthehat,项目名称:Limo,代码行数:11,代码来源:ObjectContextBase.cs

示例15: ToString

		public string ToString (SaveOptions options)
		{
			StringWriter sw = new StringWriter ();
			XmlWriterSettings s = new XmlWriterSettings ();
			s.ConformanceLevel = ConformanceLevel.Auto;
			s.Indent = options != SaveOptions.DisableFormatting;
			XmlWriter xw = XmlWriter.Create (sw, s);
			WriteTo (xw);
			xw.Close ();
			return sw.ToString ();
		}
开发者ID:user277,项目名称:mono,代码行数:11,代码来源:XNode.cs


注:本文中的SaveOptions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。