• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# SaveOptions类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: ToXmlText

        /// <summary>
        /// 把 XElement 转换为 XML 格式的字符串
        /// </summary>
        /// <param name="rootElement"></param>
        /// <param name="saveOptions"></param>
        /// <returns></returns>
        public static string ToXmlText(this XElement rootElement, SaveOptions saveOptions)
        {
            XDocument xdoc = new XDocument(rootElement);
            xdoc.Declaration = new XDeclaration("1.0", "gb2312", null);

            MemoryStream htmlStream = new MemoryStream();
            xdoc.Save(htmlStream, saveOptions);

            string htmlText = Encoding.GetEncoding("GB2312").GetString(htmlStream.ToArray());
            htmlStream.Close();

            return htmlText;
        }
开发者ID:dayuhan,项目名称:NETWORK,代码行数:19,代码来源:XmlExtensions.cs


示例17: SaveChanges

        public override int SaveChanges(SaveOptions options)
        {
            var si = SessionInfo.Get();
            if (sharedClient != null && si.currentTopicId != -1 && si.discussion != null)
            {
                //added
                foreach (ObjectStateEntry entry in ObjectStateManager.GetObjectStateEntries(EntityState.Added))
                {
                    if (entry.Entity is ArgPoint)
                    {
                        ((ArgPoint) entry.Entity).ChangesPending = false;
                        sharedClient.clienRt.SendStatsEvent(StEvent.BadgeCreated,
                                                            si.person.Id, si.discussion.Id, si.currentTopicId,
                                                            DeviceType.Wpf);
                    }
                }

                //edited
                foreach (ObjectStateEntry entry in ObjectStateManager.GetObjectStateEntries(EntityState.Modified))
                {
                    if (entry.Entity is ArgPoint)
                    {
                        ((ArgPoint) entry.Entity).ChangesPending = false;
                        sharedClient.clienRt.SendStatsEvent(StEvent.BadgeEdited,
                                                            SessionInfo.Get().person.Id,
                                                            si.discussion.Id,
                                                            si.currentTopicId,
                                                            DeviceType.Wpf);
                    }
                }

                //sources/comments/media modified
                foreach (ObjectStateEntry entry in ObjectStateManager.GetObjectStateEntries(EntityState.Unchanged))
                {
                    if (entry.Entity is ArgPoint)
                    {
                        var ap = (ArgPoint) entry.Entity;
                        if (ap.ChangesPending)
                        {
                            ap.ChangesPending = false;
                            sharedClient.clienRt.SendStatsEvent(StEvent.BadgeEdited,
                                                                si.person.Id, si.discussion.Id, si.currentTopicId,
                                                                DeviceType.Wpf);
                        }
                    }
                }
            }

            return base.SaveChanges(options);
        }
开发者ID:gdlprj,项目名称:duscusys,代码行数:50,代码来源:StatsTrackingDbCtx.cs


示例18: Custom_processor_of_embedded_images

        // ExStart:PrefixForURLsHelper
        private static string Custom_processor_of_embedded_images(SaveOptions.ResourceSavingInfo resourceSavingInfo)
        {
            // ____________________________________________________________________________
            //    This sample method saving strategy method saves image-files in some folder
            //    (including raster image files that are exctracted from that SVGs)
            //    Then it returns specific custom artificial  path
            //    to be used as value of 'src' or 'data' relevant attribute in generated host-SVG(or HTML)
            // ____________________________________________________________________________

            //---------------------------------------------------------
            // 1) All other files(f.e. fonts) will be processed with converter itself cause for them flag
            //   resourceSavingInfo.CustomProcessingCancelled is set to 'true'
            //---------------------------------------------------------
            if (!(resourceSavingInfo is HtmlSaveOptions.HtmlImageSavingInfo))
            {
                resourceSavingInfo.CustomProcessingCancelled = true;
                return "";
            }
            //---------------------------------------------------------
            // 1) Create target folder if not created yet
            //---------------------------------------------------------
            string dataDir = RunExamples.GetDataDir_AsposePdf_DocumentConversion_PDFToHTMLFormat();
            string outDir = dataDir + @"output\36297_files\";
            string outPath = outDir + Path.GetFileName(resourceSavingInfo.SupposedFileName);
            if (!Directory.Exists(outDir))
            {
                Directory.CreateDirectory(outDir);
            }
            //---------------------------------------------------------
            // 3) Write supplied image to that folder
            //---------------------------------------------------------
            System.IO.BinaryReader reader = new BinaryReader(resourceSavingInfo.ContentStream);
            System.IO.File.WriteAllBytes(dataDir, reader.ReadBytes((int)resourceSavingInfo.ContentStream.Length));
            //---------------------------------------------------------
            // 4) Return customized specific URL to be used to refer
            //    just created image in parent SVG (or HTML)
            //---------------------------------------------------------
            HtmlSaveOptions.HtmlImageSavingInfo asHtmlImageSavingInfo = resourceSavingInfo as HtmlSaveOptions.HtmlImageSavingInfo;
            if (asHtmlImageSavingInfo.ParentType == HtmlSaveOptions.ImageParentTypes.SvgImage)
            {
                return "http:// Localhost:255/" + resourceSavingInfo.SupposedFileName;
            }
            else
            {
                return "http:// Localhost:GetImage/imageID=" + resourceSavingInfo.SupposedFileName;
            }
        }
开发者ID:aspose-pdf,项目名称:Aspose.Pdf-for-.NET,代码行数:48,代码来源:PrefixForURLs.cs


示例19: ToContent

        public static HttpContent ToContent(this XElement element, SaveOptions options = SaveOptions.None)
        {
            FX.ThrowIfNull(element, "element");

            var stream = new MemoryStream();
            try
            {
                element.Save(stream, options);
                stream.Position = 0;
                var content = new StreamContent(stream);
                return content;
            }
            catch
            {
                stream.Dispose();
                throw;
            }
        }
开发者ID:AlexZeitler,项目名称:WcfHttpMvcFormsAuth,代码行数:18,代码来源:XElementContentExtensions.cs


示例20: SaveChanges

        public override int SaveChanges(SaveOptions options)
        {
            var changes = this.ObjectStateManager.GetObjectStateEntries(
                                 EntityState.Modified |
                                 EntityState.Added |
                                 EntityState.Deleted);
            foreach (var change in changes) {
                var entity = change.Entity as IEntityTracking;
                if (entity != null) {
                    if (change.State == EntityState.Deleted) {
                        change.ChangeState(EntityState.Modified);
                        entity.IsDeleted = true;
                    }
                    entity.LastUpdated = DateTime.Now.Ticks;
                }
            }

            return base.SaveChanges(options);
        }
开发者ID:Thejasree,项目名称:JavaScriptReference,代码行数:19,代码来源:ReferenceDBEntities.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SaveRequest类代码示例发布时间:2022-05-24
下一篇:
C# SaveFlag类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap