private object DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part, bool isRequest) { object val; try { val = part.ReadObject(reader); } catch (System.InvalidOperationException e) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException( SR.Format(SR.SFxInvalidMessageBodyErrorDeserializingParameter, part.Description.Namespace, part.Description.Name), e)); } catch (System.Runtime.Serialization.InvalidDataContractException e) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException( SR.Format(SR.SFxInvalidMessageBodyErrorDeserializingParameter, part.Description.Namespace, part.Description.Name), e)); } catch (System.FormatException e) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( CreateDeserializationFailedFault( SR.Format(SR.SFxInvalidMessageBodyErrorDeserializingParameterMore, part.Description.Namespace, part.Description.Name, e.Message), e)); } catch (System.Runtime.Serialization.SerializationException e) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( CreateDeserializationFailedFault( SR.Format(SR.SFxInvalidMessageBodyErrorDeserializingParameterMore, part.Description.Namespace, part.Description.Name, e.Message), e)); } return(val); }
//Shows the tool tip for the part that was clicked on in the store public void ShowPartDesc(PartInfo partInfo) { if (partInfo != null) { partDesc.ShowPartInfo(partInfo); } }
private void GeneratePartType(Dictionary <XmlMembersMapping, XmlMembersMapping> alreadyExported, MessagePartDescription part) { if (this.partInfoTable.ContainsKey(part)) { PartInfo info = this.partInfoTable[part]; XmlMembersMapping membersMapping = info.MembersMapping; XmlMemberMapping memberMapping = info.MemberMapping; if (!alreadyExported.ContainsKey(membersMapping)) { if (info.IsEncoded) { this.SoapExporter.ExportMembersMapping(membersMapping); } else { this.XmlExporter.ExportMembersMapping(membersMapping); } alreadyExported.Add(membersMapping, membersMapping); } CodeAttributeDeclarationCollection metadata = new CodeAttributeDeclarationCollection(); if (info.IsEncoded) { this.SoapExporter.AddMappingMetadata(metadata, memberMapping, false); } else { this.XmlExporter.AddMappingMetadata(metadata, memberMapping, part.Namespace, false); } part.BaseType = this.GetTypeName(memberMapping); this.operationGenerator.ParameterTypes.Add(part, new CodeTypeReference(part.BaseType)); this.operationGenerator.ParameterAttributes.Add(part, metadata); } }
static private PartInfo[] GetMonsterPartsInfo(XmlNode node) { List <PartInfo> parts = new List <PartInfo>(); if (node == null) { return(null); } XmlNodeList mParts = node.SelectNodes("Parts/Part"); foreach (XmlNode partData in mParts) { PartInfo pInfo = new PartInfo { Id = partData.Attributes["Name"]?.Value ?? "MONSTER_PART_UNKNOWN", IsRemovable = bool.Parse(partData.Attributes["IsRemovable"]?.Value ?? "false"), GroupId = partData.Attributes["Group"]?.Value ?? "MISC" }; XmlNodeList breaks = partData.SelectNodes("Break"); pInfo.BreakThresholds = breaks != null ? breaks.Cast <XmlNode>().Select(b => int.Parse(b.Attributes["Threshold"].Value)).ToArray() : Array.Empty <int>(); parts.Add(pInfo); } return(parts.ToArray()); }
public Part(Monster owner, PartInfo partInfo, int index) { Owner = owner; this.partInfo = partInfo; id = index; HasBreakConditions = BreakThresholds.Where(p => p.HasConditions).Count() > 0; }
private void DeserializeParameters(XmlDictionaryReader reader, PartInfo[] parts, object[] parameters, bool isRequest) { int num = 0; while (reader.IsStartElement()) { for (int i = num; i < parts.Length; i++) { PartInfo part = parts[i]; if (part.Serializer.IsStartObject(reader)) { object obj2 = this.DeserializeParameter(reader, part, isRequest); parameters[part.Description.Index] = obj2; num = i + 1; } else { parameters[part.Description.Index] = null; } } if (reader.IsStartElement()) { OperationFormatter.TraceAndSkipElement(reader); } } }
protected override void AddHeadersToMessage(Message message, MessageDescription messageDescription, object[] parameters, bool isRequest) { MessageInfo info = isRequest ? this.requestMessageInfo : this.replyMessageInfo; PartInfo[] headerParts = info.HeaderParts; if ((headerParts != null) && (headerParts.Length != 0)) { MessageHeaders headers = message.Headers; for (int i = 0; i < headerParts.Length; i++) { PartInfo headerPart = headerParts[i]; MessageHeaderDescription description = (MessageHeaderDescription)headerPart.Description; object parameterValue = parameters[description.Index]; if (description.Multiple) { if (parameterValue != null) { bool isXmlElement = description.Type == typeof(XmlElement); foreach (object obj3 in (IEnumerable)parameterValue) { this.AddMessageHeaderForParameter(headers, headerPart, message.Version, obj3, isXmlElement); } } } else { this.AddMessageHeaderForParameter(headers, headerPart, message.Version, parameterValue, false); } } } }
private object DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part, bool isRequest) { object obj2; XmlObjectSerializer serializer = part.Serializer; try { obj2 = serializer.ReadObject(reader, false); } catch (InvalidOperationException exception) { throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxInvalidMessageBodyErrorDeserializingParameter", new object[] { part.Description.Namespace, part.Description.Name }), exception)); } catch (InvalidDataContractException exception2) { throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(System.ServiceModel.SR.GetString("SFxInvalidMessageBodyErrorDeserializingParameter", new object[] { part.Description.Namespace, part.Description.Name }), exception2)); } catch (FormatException exception3) { throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(OperationFormatter.CreateDeserializationFailedFault(System.ServiceModel.SR.GetString("SFxInvalidMessageBodyErrorDeserializingParameterMore", new object[] { part.Description.Namespace, part.Description.Name, exception3.Message }), exception3)); } catch (SerializationException exception4) { throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(OperationFormatter.CreateDeserializationFailedFault(System.ServiceModel.SR.GetString("SFxInvalidMessageBodyErrorDeserializingParameterMore", new object[] { part.Description.Namespace, part.Description.Name, exception4.Message }), exception4)); } return(obj2); }
public void Deletes(int[] ids) { using (IGenericTransaction tx = this.m_UnitOfWork.BeginTransaction()) { try { foreach (int id in ids) { PartBorrowReturn pbr = this.m_UnitOfWork.GetRepositoryBase <PartBorrowReturn>().Get(id); IList <PartBorrowItem> pbiList = this.m_UnitOfWork.GetRepositoryBase <PartBorrowItem>().Query().Where(p => p.BorrowID == pbr.BorrowID && p.PartID == pbr.PartID).ToList(); if (pbiList.Count > 0) { PartBorrowItem pbi = pbiList[0]; pbi.ReturnNum = pbi.ReturnNum - pbr.ReturnNum; this.m_UnitOfWork.GetRepositoryBase <PartBorrowItem>().Update(pbi, null); } PartInfo part = this.m_UnitOfWork.GetRepositoryBase <PartInfo>().Get(pbr.PartID); part.Inventory -= pbr.ReturnNum; this.m_UnitOfWork.GetRepositoryBase <PartInfo>().Update(part, null); tx.Commit(); base.Delete(pbr); } } catch (Exception ex) { tx.Rollback(); logger.Error(ex.Message); throw; } } }
private void DeserializeParameters(XmlDictionaryReader reader, PartInfo[] parts, object[] parameters) { if (parts.Length != parameters.Length) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new ArgumentException(SR.Format(SR.SFxParameterCountMismatch, "parts", parts.Length, "parameters", parameters.Length), "parameters")); } int nextPartIndex = 0; while (reader.IsStartElement()) { for (int i = nextPartIndex; i < parts.Length; i++) { PartInfo part = parts[i]; if (IsPartElement(reader, part)) { parameters[part.Description.Index] = DeserializeParameter(reader, parts[i]); nextPartIndex = i + 1; } else { parameters[part.Description.Index] = null; } } if (reader.IsStartElement()) { OperationFormatter.TraceAndSkipElement(reader); } } }
private void CompressAttachment(Attachment attachment) { PartInfo referenced = _partInfos.FirstOrDefault(attachment.Matches); if (referenced == null) { throw new InvalidOperationException( $"Can't compress attachment {attachment.Id} because no matching PartInfo element was found in UserMessage"); } VirtualStream outputStream = VirtualStream.Create( attachment.EstimatedContentSize > -1 ? attachment.EstimatedContentSize : VirtualStream.ThresholdMax); CompressionLevel compressionLevel = DetermineCompressionLevelFor(attachment); using (var gzipCompression = new GZipStream(outputStream, compressionLevel, leaveOpen: true)) { attachment.Content.CopyTo(gzipCompression); } outputStream.Position = 0; attachment.MimeType = attachment.ContentType; attachment.CompressionType = CompressionType; referenced.CompressionType = CompressionType; attachment.UpdateContent(outputStream, CompressionType); }
public virtual ActionResult Audit(string[] id) { try { IList <PartInventoryDetail> partInventoryDetailList = this.service.GetGenericService <PartInventoryDetail>().All("InventoryID = '" + id[0] + "'", "InventoryID", true); if (partInventoryDetailList != null) { ServiceBase <PartInfo> partInfoventoryService = this.service.GetGenericService <PartInfo>(); foreach (PartInventoryDetail partInventoryDetai in partInventoryDetailList) { PartInfo partInfo = partInfoventoryService.Get(partInventoryDetai.PartID); partInfo.Inventory = partInventoryDetai.ActualValue; partInfoventoryService.Update(partInfo, null); } } string userId = AuthorizationService.CurrentUserID; ServiceBase <PartInventory> partInventoryService = this.service.GetGenericService <PartInventory>(); PartInventory partInventory = partInventoryService.Get(id[0]); partInventory.Auditor = userId; partInventory.AuditTime = DateTime.Now; partInventory.AuditStatus = 1; partInventoryService.Update(partInventory, null); return(OperateResult(true, Lang.Msg_Operate_Success, null)); } catch (Exception ex) { if (ex.InnerException != null) { ex = ex.InnerException; } log.Error(ex.Message, ex); return(OperateResult(false, Lang.Msg_Operate_Failed, null)); } }
private PartInfo CreatePartInfo(MessagePartDescription part, OperationFormatStyle style, DataContractSerializerOperationBehavior serializerFactory) { string ns = (style == OperationFormatStyle.Rpc || part.Namespace == null) ? string.Empty : part.Namespace; PartInfo partInfo = new PartInfo(part, AddToDictionary(part.Name), AddToDictionary(ns), _knownTypes, serializerFactory); return(partInfo); }
public OpenXmlDocumentModel(Stream output, WordOpenXmlWriter.CreateXmlStream createXmlStream, ScalabilityCache scalabilityCache) { _createXmlStream = createXmlStream; _zipPackage = Package.Open(output, FileMode.Create); _documentPart = (_currentPart = new PartInfo()); _currentPart.Part = new DocumentPart(); _manager = new PartManager(ZipPackage); Relationship relationship = _manager.AddStreamingRootPartToTree("application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument", "word/document.xml"); WriteStylesheet(); WriteSettings(); _currentPart.PartName = relationship.RelatedPart; _currentPart.Stream = _createXmlStream("document"); _currentPart.Writer = new InterleavingWriter(_currentPart.Stream, scalabilityCache); _currentHeaderFooterReferences = default(TemporaryHeaderFooterReferences); _tags = new Stack <OoxmlComplexType>(); _currentPart.Writer.TextWriter.Write(OoxmlPart.XmlDeclaration); CT_Document cT_Document = new CT_Document(); cT_Document.WriteOpenTag(_currentPart.Writer.TextWriter, _currentPart.Part.Tag, _currentPart.Part.Namespaces); _tags.Push(cT_Document); CT_Body ctObject = new CT_Body(); WriteStartTag(ctObject, CT_Document.BodyElementName); _currentPart.TableContext = new TableContext(_currentPart.Writer, inHeaderFooter: false); _listManager = new OpenXmlListNumberingManager(); _sectionProperties = new OpenXmlSectionPropertiesModel(); }
protected override void AddHeadersToMessage(Message message, MessageDescription messageDescription, object[] parameters, bool isRequest) { MessageInfo messageInfo = isRequest ? requestMessageInfo : replyMessageInfo; PartInfo[] headerParts = messageInfo.HeaderParts; if (headerParts == null || headerParts.Length == 0) { return; } MessageHeaders headers = message.Headers; for (int i = 0; i < headerParts.Length; i++) { PartInfo headerPart = headerParts[i]; MessageHeaderDescription headerDescription = (MessageHeaderDescription)headerPart.Description; object headerValue = parameters[headerDescription.Index]; if (headerDescription.Multiple) { if (headerValue != null) { bool isXmlElement = headerDescription.Type == typeof(XmlElement); foreach (object headerItemValue in (IEnumerable)headerValue) { AddMessageHeaderForParameter(headers, headerPart, message.Version, headerItemValue, isXmlElement); } } } else { AddMessageHeaderForParameter(headers, headerPart, message.Version, headerValue, false /*isXmlElement*/); } } }
private void DeserializeParameters(XmlDictionaryReader reader, PartInfo[] parts, object[] parameters, bool isRequest) { int nextPartIndex = 0; while (reader.IsStartElement()) { for (int i = nextPartIndex; i < parts.Length; i++) { PartInfo part = parts[i]; if (part.Serializer.IsStartObject(reader)) { object parameterValue = DeserializeParameter(reader, part, isRequest); parameters[part.Description.Index] = parameterValue; nextPartIndex = i + 1; } else { parameters[part.Description.Index] = null; } } if (reader.IsStartElement()) { TraceAndSkipElement(reader); } } }
/// <summary> /// 点击一个分p时 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void ListView_ItemClick(object sender, ItemClickEventArgs e) { List <string> url = new List <string>(); //获取被点击的分p PartInfo clickedItem = e.ClickedItem as PartInfo; //获取视频地址; url = await info.GetPlayUrl(clickedItem.PartNumber - 1); if (url.Count < 1) { Link.ShowToast("获取视频播放地址失败,请稍后再试"); return; } //打开播放器 var param = new MediaPlayer.MediaPlayerSource(); param.Hid = info.Hid; param.Title = info.Title; param.PartTitle = clickedItem.PartTitle; param.PlayList = url; //本地文件夹禁止有/字符.而网页url绝对有这个字符 param.IsLocalFile = !url[0].Contains("/"); param.Part = clickedItem.PartNumber - 1; param.Tid = info.TypeId; Frame frame = Window.Current.Content as Frame; frame.Navigate(typeof(MediaPlayer), param, new DrillInNavigationTransitionInfo()); }
private void DeserializeParameters(XmlDictionaryReader reader, PartInfo[] parts, object[] parameters) { if (parts.Length != parameters.Length) { throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(System.ServiceModel.SR.GetString("SFxParameterCountMismatch", new object[] { "parts", parts.Length, "parameters", parameters.Length }), "parameters")); } int num = 0; while (reader.IsStartElement()) { for (int i = num; i < parts.Length; i++) { PartInfo part = parts[i]; if (this.IsPartElement(reader, part)) { parameters[part.Description.Index] = this.DeserializeParameter(reader, parts[i]); num = i + 1; } else { parameters[part.Description.Index] = null; } } if (reader.IsStartElement()) { OperationFormatter.TraceAndSkipElement(reader); } } }
static void WriteIndices(PartInfo p, StreamWriter writer) { var format = "f {0} {1} {2}"; if (p.Normals && p.Texcoords) { format = "f {0}/{0}/{0} {1}/{1}/{1} {2}/{2}/{2}"; } else if (p.Normals) { format = "f {0}//{0} {1}//{1} {2}//{2}"; } else if (p.Texcoords) { format = "f {0}/{0} {1}/{1} {2}/{2}"; } writer.WriteLine("o {0}", p.Name); int partIndex = 1; for (int j = p.Ref.StartMesh; j < p.Ref.StartMesh + p.Ref.MeshCount; j++) { writer.WriteLine("g {1}_vms{0}", partIndex++, p.Name); var header = p.Ref.Mesh.Meshes[j]; var ofs = header.StartVertex + p.Ref.StartVertex + p.Offset; var idxOffset = header.TriangleStart; for (int i = 0; i < header.NumRefVertices; i += 3) { var idxA = ofs + p.Ref.Mesh.Indices[idxOffset + i]; var idxB = ofs + p.Ref.Mesh.Indices[idxOffset + i + 1]; var idxC = ofs + p.Ref.Mesh.Indices[idxOffset + i + 2]; writer.WriteLine(format, idxA, idxB, idxC); } } }
public Dimension(Form pForm, PartInfo partInfo, string OpName) { InitializeComponent(); //將父層的Form傳進來 parentForm = pForm; panel = SGCControlPanel.PrimaryGrid; panel.Columns["Delete"].EditorType = typeof(DeleteControlData); InitialLabel(partInfo, OpName); /* * try * { * //取得所有刀號資料 * NCGroup ToolGroup = displayPart.CAMSetup.GetRoot(CAMSetup.View.MachineTool); * CAMObject[] ListTool = ToolGroup.GetMembers(); * ListToolNo.Add(""); * foreach (CAMObject i in ListTool) * { * if (i is NXOpen.CAM.Tool) ListToolNo.Add("T" + CaxOper.AskToolNumber(i)); * } * } * catch (System.Exception ex) * { * MessageBox.Show("取得刀號失敗"); * return; * } */ }
private static (bool, PartInfo) SelectReferencedPartInfo( string attachmentId, IEnumerable <PartInfo> referencedPartInfos) { PartInfo partInfo = referencedPartInfos.FirstOrDefault(i => i.Href?.Contains(attachmentId) == true); return(partInfo != null, partInfo); }
internal void Add(MessagePartDescription part, XmlMemberMapping memberMapping, XmlMembersMapping membersMapping, bool isEncoded) { PartInfo partInfo = new PartInfo(); partInfo.MemberMapping = memberMapping; partInfo.MembersMapping = membersMapping; partInfo.IsEncoded = isEncoded; partInfoTable[part] = partInfo; }
public BotInfo(int id, string name, int tier, IEnumerable <PartInfo> equipment, PartInfo bodyType, IEnumerable <BehaviorInfo> behavior) { this.id = id; this.name = name; this.tier = tier; this.equipment = new List <PartInfo>(equipment); this.bodyType = bodyType; this.behavior = new List <BehaviorInfo>(behavior); }
//绑定零件ID信息 protected void BindPartID(DM_Factory factory, List <ProjectInfo> arrProjectInfo) { string strError = ""; ServerConnection conn = new ServerConnection(factory.ServerID, factory.DatabaseID); List <DM_ModelProject> arrProject = CmdQuery.GetProjectArray(conn, ref strError); if (arrProject == null || arrProject.Count == 0) { return; } foreach (DM_ModelProject project in arrProject) { ProjectInfo curProject = null; foreach (ProjectInfo projectInfo in arrProjectInfo) { if (projectInfo.ProjectName == project.ProjectName) { projectInfo.ProjectID = project.ProjectID; curProject = projectInfo; break; } } //绑定所有标签中的零件ID if (curProject != null) { List <DM_ModelPart> arrPart = CmdQuery.GetPartArray(conn, project.ProjectID, ref strError); foreach (DM_ModelPart part in arrPart) { for (int i = 0; i < curProject.Tags.Length; i++) { if (curProject.Tags[i].GetPartInfo() != null) //标签需要零件信息 { PartInfo partInfo = curProject.Tags[i].GetPartInfo(); if (partInfo.PartName == part.PartName) { partInfo.PartID = part.PartID; } } else if (curProject.Tags[i].GetPartArray() != null) //标签需要零件数组信息 { PartInfo[] arrPartInfo = curProject.Tags[i].GetPartArray(); for (int j = 0; j < arrPartInfo.Length; j++) { if (arrPartInfo[j].PartName == part.PartName) { arrPartInfo[j].PartID = part.PartID; } } } } } } } }
private static PartInfo[] AddToDictionary(XmlDictionary dictionary, MessagePartDescriptionCollection parts, bool isRpc) { PartInfo[] partInfos = new PartInfo[parts.Count]; for (int i = 0; i < parts.Count; i++) { partInfos[i] = AddToDictionary(dictionary, parts[i], isRpc); } return(partInfos); }
protected override InventoryItem DeserializeJson(DeserializationHelper helper) { int pid = helper.GetValue <int>("pid"); int count = helper.GetValue("count", 0); PartInfo part = DataManager.Instance.GetPart(pid); return(new InventoryItem(part, count)); }
private void SerializeParameters(XmlDictionaryWriter writer, PartInfo[] parts, object[] parameters) { for (int i = 0; i < parts.Length; i++) { PartInfo part = parts[i]; object graph = parameters[part.Description.Index]; SerializeParameter(writer, part, graph); } }
private static Payload CreateDeliverPayload(PartInfo part) { return(new Payload { Id = part.Href, MimeType = part.HasMimeType ? part.MimeType : null, PayloadProperties = part.Properties.Select(p => new PayloadProperty(p.Key, p.Value)).ToArray() }); }
private object DeserializeParameter(XmlDictionaryReader reader, PartInfo part) { if (((reader.AttributeCount > 0) && reader.MoveToAttribute(this.xsiNilLocalName.Value, this.xsiNilNamespace.Value)) && reader.ReadContentAsBoolean()) { reader.Skip(); return(null); } return(part.ReadValue(reader)); }
public static DumpObjectStatus DumpObj(IDrawable model, string path) { try { var status = DumpObjectStatus.Ok; using (var writer = new StreamWriter(path)) { if (model is CmpFile) { writer.WriteLine("# exported cmp"); List <PartInfo> infos = new List <PartInfo>(); int cOffset = 1; foreach (var part in ((CmpFile)model).Parts) { var vms = part.Value.Model.Levels[0].Mesh; var info = new PartInfo() { Ref = part.Value.Model.Levels[0], Offset = cOffset, Name = GetPath(part.Value.Model.Path, cOffset) }; var mat = part.Value.Construct == null ? Matrix4.Identity : part.Value.Construct.Transform; WriteVertices(ref status, ref info.Normals, ref info.Texcoords, writer, vms, mat); infos.Add(info); cOffset += vms.VertexCount; } foreach (var info in infos) { WriteIndices(info, writer); } } else if (model is ModelFile) { writer.WriteLine("# exported 3db"); var mdl = (ModelFile)model; var info = new PartInfo() { Ref = mdl.Levels[0], Offset = 1, Name = GetPath(mdl.Path, 1) }; WriteVertices(ref status, ref info.Normals, ref info.Texcoords, writer, mdl.Levels[0].Mesh, Matrix4.Identity); WriteIndices(info, writer); } else { return(DumpObjectStatus.Fail); } return(status); } } catch (Exception) { return(DumpObjectStatus.Fail); } }
/// <summary> /// Disposes the provided parts. /// </summary> public void Dispose(PartInfo[] parts) { using (LogGroup logGroup = LogGroup.Start("Disposing the parts.", NLog.LogLevel.Debug)) { foreach (PartInfo part in parts) { PartState.Parts.Remove( PartState.Parts[part.Key] ); } } }
public PrimitiveOperationFormatter(OperationDescription description, bool isRpc) { if (description == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("description"); OperationFormatter.Validate(description, isRpc, false/*isEncoded*/); this.operation = description; #pragma warning suppress 56506 // Microsoft, OperationDescription.Messages never be null this.requestMessage = description.Messages[0]; if (description.Messages.Count == 2) this.responseMessage = description.Messages[1]; int stringCount = 3 + requestMessage.Body.Parts.Count; if (responseMessage != null) stringCount += 2 + responseMessage.Body.Parts.Count; XmlDictionary dictionary = new XmlDictionary(stringCount * 2); xsiNilLocalName = dictionary.Add("nil"); xsiNilNamespace = dictionary.Add(System.Xml.Schema.XmlSchema.InstanceNamespace); OperationFormatter.GetActions(description, dictionary, out this.action, out this.replyAction); if (requestMessage.Body.WrapperName != null) { requestWrapperName = AddToDictionary(dictionary, requestMessage.Body.WrapperName); requestWrapperNamespace = AddToDictionary(dictionary, requestMessage.Body.WrapperNamespace); } requestParts = AddToDictionary(dictionary, requestMessage.Body.Parts, isRpc); if (responseMessage != null) { if (responseMessage.Body.WrapperName != null) { responseWrapperName = AddToDictionary(dictionary, responseMessage.Body.WrapperName); responseWrapperNamespace = AddToDictionary(dictionary, responseMessage.Body.WrapperNamespace); } responseParts = AddToDictionary(dictionary, responseMessage.Body.Parts, isRpc); if (responseMessage.Body.ReturnValue != null && responseMessage.Body.ReturnValue.Type != typeof(void)) { returnPart = AddToDictionary(dictionary, responseMessage.Body.ReturnValue, isRpc); } } }
public PrimitiveOperationFormatter(OperationDescription description, bool isRpc) { if (description == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("description"); OperationFormatter.Validate(description, isRpc, false/*isEncoded*/); _operation = description; _requestMessage = description.Messages[0]; if (description.Messages.Count == 2) _responseMessage = description.Messages[1]; int stringCount = 3 + _requestMessage.Body.Parts.Count; if (_responseMessage != null) stringCount += 2 + _responseMessage.Body.Parts.Count; XmlDictionary dictionary = new XmlDictionary(stringCount * 2); _xsiNilLocalName = dictionary.Add("nil"); _xsiNilNamespace = dictionary.Add(EndpointAddressProcessor.XsiNs); OperationFormatter.GetActions(description, dictionary, out _action, out _replyAction); if (_requestMessage.Body.WrapperName != null) { _requestWrapperName = AddToDictionary(dictionary, _requestMessage.Body.WrapperName); _requestWrapperNamespace = AddToDictionary(dictionary, _requestMessage.Body.WrapperNamespace); } _requestParts = AddToDictionary(dictionary, _requestMessage.Body.Parts, isRpc); if (_responseMessage != null) { if (_responseMessage.Body.WrapperName != null) { _responseWrapperName = AddToDictionary(dictionary, _responseMessage.Body.WrapperName); _responseWrapperNamespace = AddToDictionary(dictionary, _responseMessage.Body.WrapperNamespace); } _responseParts = AddToDictionary(dictionary, _responseMessage.Body.Parts, isRpc); if (_responseMessage.Body.ReturnValue != null && _responseMessage.Body.ReturnValue.Type != typeof(void)) { _returnPart = AddToDictionary(dictionary, _responseMessage.Body.ReturnValue, isRpc); } } }
protected void ParsePartition(byte[] aEBR, UInt32 aLoc) { byte xSystemID = aEBR[aLoc + 4]; // SystemID = 0 means no partition //TODO: Extended Partition Table if (xSystemID == 0x5 || xSystemID == 0xF || xSystemID == 0x85) { //Another EBR Detected } else if (xSystemID != 0) { UInt32 xStartSector = aEBR.ToUInt32(aLoc + 8); UInt32 xSectorCount = aEBR.ToUInt32(aLoc + 12); var xPartInfo = new PartInfo(xSystemID, xStartSector, xSectorCount); Partitions.Add(xPartInfo); } }
/// <summary> /// Creates mock parts that can be used during testing. /// </summary> public void CreateMockParts(PartFileNamer namer) { PartInfo info1 = new PartInfo(); info1.Action = "Create"; info1.TypeName = "User"; info1.PartFilePath = "Parts/User-Create.ascx"; string part1Path = namer.CreatePartFilePath(info1); if (!Directory.Exists(Path.GetDirectoryName(part1Path))) Directory.CreateDirectory(Path.GetDirectoryName(part1Path)); using (StreamWriter writer = File.CreateText(part1Path)) { writer.Write("[mock content]"); writer.Close(); } }
public PrimitiveOperationFormatter(OperationDescription description, bool isRpc) { if (description == null) { throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("description"); } OperationFormatter.Validate(description, isRpc, false); this.operation = description; this.requestMessage = description.Messages[0]; if (description.Messages.Count == 2) { this.responseMessage = description.Messages[1]; } int num = 3 + this.requestMessage.Body.Parts.Count; if (this.responseMessage != null) { num += 2 + this.responseMessage.Body.Parts.Count; } XmlDictionary dictionary = new XmlDictionary(num * 2); this.xsiNilLocalName = dictionary.Add("nil"); this.xsiNilNamespace = dictionary.Add("http://www.w3.org/2001/XMLSchema-instance"); OperationFormatter.GetActions(description, dictionary, out this.action, out this.replyAction); if (this.requestMessage.Body.WrapperName != null) { this.requestWrapperName = AddToDictionary(dictionary, this.requestMessage.Body.WrapperName); this.requestWrapperNamespace = AddToDictionary(dictionary, this.requestMessage.Body.WrapperNamespace); } this.requestParts = AddToDictionary(dictionary, this.requestMessage.Body.Parts, isRpc); if (this.responseMessage != null) { if (this.responseMessage.Body.WrapperName != null) { this.responseWrapperName = AddToDictionary(dictionary, this.responseMessage.Body.WrapperName); this.responseWrapperNamespace = AddToDictionary(dictionary, this.responseMessage.Body.WrapperNamespace); } this.responseParts = AddToDictionary(dictionary, this.responseMessage.Body.Parts, isRpc); if ((this.responseMessage.Body.ReturnValue != null) && (this.responseMessage.Body.ReturnValue.Type != typeof(void))) { this.returnPart = AddToDictionary(dictionary, this.responseMessage.Body.ReturnValue, isRpc); } } }
public void AddContent(PartInfo rel, Stream sourceStream) { PartInfo parentPart = GetPart(rel.RelatedTo); PartInfo clonedPart = new PartInfo(this, rel); string sContentType; if (ContentIsInternalType(rel.Type)) { sContentType = rel.GetContentType(); clonedPart.Target = RemoveLeadingSlash(clonedPart.Target); parentPart.AddRelatedItem(clonedPart); if (m_partsMap.ContainsKey(clonedPart.AbsolutePath()) && sourceStream == null) { // we have already added this content via a relationship elsewhere, don't need to write it return; } m_partsMap.Add(clonedPart.AbsolutePath(), clonedPart); if (sourceStream != null) { string partName = clonedPart.AbsolutePath(); AddZipEntry(partName, sourceStream); if (rel.ContentTypeOverriden()) m_contentTypes.Add("/" + partName, sContentType); } } else {//we should only get here for external rels - so there should never be an additional stream to add parentPart.AddRelatedItem(clonedPart); sContentType = rel.Type; if (m_partsMap.ContainsKey(clonedPart.Target)) { // we have already added this content via a relationship elsewhere, don't need to write it return; } m_partsMap.Add(clonedPart.Target, clonedPart); if (sourceStream != null) { throw new System.InvalidOperationException("Sourcestream is not null for supposedly external hyperlink part"); } } }
protected void ParsePartition(byte[] aMBR, UInt32 aLoc) { byte xSystemID = aMBR[aLoc + 4]; // SystemID = 0 means no partition if (xSystemID == 0x5 || xSystemID == 0xF || xSystemID == 0x85) { //Extended Partition Detected //DOS only knows about 05, Windows 95 introduced 0F, Linux introduced 85 //Search for logical volumes //http://thestarman.pcministry.com/asm/mbr/PartTables2.htm EBRLocation = aMBR.ToUInt32(aLoc + 8); } else if (xSystemID != 0) { UInt32 xStartSector = aMBR.ToUInt32(aLoc + 8); UInt32 xSectorCount = aMBR.ToUInt32(aLoc + 12); var xPartInfo = new PartInfo(xSystemID, xStartSector, xSectorCount); Partitions.Add(xPartInfo); } }
private void AddMessageHeaderForParameter(MessageHeaders headers, PartInfo headerPart, MessageVersion messageVersion, object parameterValue, bool isXmlElement) { string str; bool flag; bool flag2; MessageHeaderDescription headerDescription = (MessageHeaderDescription) headerPart.Description; object headerValue = OperationFormatter.GetContentOfMessageHeaderOfT(headerDescription, parameterValue, out flag, out flag2, out str); if (isXmlElement) { if (headerValue != null) { XmlElement element = (XmlElement) headerValue; headers.Add(new OperationFormatter.XmlElementMessageHeader(this, messageVersion, element.LocalName, element.NamespaceURI, flag, str, flag2, element)); } } else { headers.Add(new DataContractSerializerMessageHeader(headerPart, headerValue, flag, str, flag2)); } }
/// <summary> /// Saves the provided parts info to file. /// </summary> /// <param name="parts">An array of the parts to save to file.</param> public void SaveInfoToFile(PartInfo[] parts) { // Logging disabled to boost performance //using (LogGroup logGroup = LogGroup.StartDebug("Saving the provided parts to XML file.")) //{ string path = FileNamer.PartsInfoFilePath; //LogWriter.Debug("Path : " + path); if (!Directory.Exists(Path.GetDirectoryName(path))) Directory.CreateDirectory(Path.GetDirectoryName(path)); using (StreamWriter writer = File.CreateText(path)) { XmlSerializer serializer = new XmlSerializer(parts.GetType()); serializer.Serialize(writer, parts); writer.Close(); } //} }
private object DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part, bool isRequest) { object obj2; XmlObjectSerializer serializer = part.Serializer; try { obj2 = serializer.ReadObject(reader, false); } catch (InvalidOperationException exception) { throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxInvalidMessageBodyErrorDeserializingParameter", new object[] { part.Description.Namespace, part.Description.Name }), exception)); } catch (InvalidDataContractException exception2) { throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(System.ServiceModel.SR.GetString("SFxInvalidMessageBodyErrorDeserializingParameter", new object[] { part.Description.Namespace, part.Description.Name }), exception2)); } catch (FormatException exception3) { throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(OperationFormatter.CreateDeserializationFailedFault(System.ServiceModel.SR.GetString("SFxInvalidMessageBodyErrorDeserializingParameterMore", new object[] { part.Description.Namespace, part.Description.Name, exception3.Message }), exception3)); } catch (SerializationException exception4) { throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(OperationFormatter.CreateDeserializationFailedFault(System.ServiceModel.SR.GetString("SFxInvalidMessageBodyErrorDeserializingParameterMore", new object[] { part.Description.Namespace, part.Description.Name, exception4.Message }), exception4)); } return obj2; }
private void SerializeParameter(XmlDictionaryWriter writer, PartInfo part, object graph) { if (part.Description.Multiple) { if (graph != null) { foreach (object obj2 in (IEnumerable) graph) { this.SerializeParameterPart(writer, part, obj2); } } } else { this.SerializeParameterPart(writer, part, graph); } }
private void SerializeParameterPart(XmlDictionaryWriter writer, PartInfo part, object graph) { try { part.Serializer.WriteObject(writer, graph); } catch (SerializationException exception) { throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(System.ServiceModel.SR.GetString("SFxInvalidMessageBodyErrorSerializingParameter", new object[] { part.Description.Namespace, part.Description.Name, exception.Message }), exception)); } }
Dictionary<Block, PartInfo> BuildPartitionInfo() { var partInfo = new Dictionary<Block, PartInfo>(); foreach (var block in blockGraph.Nodes) { if (uni.IsUniform(impl.Name, block)) continue; var parts = block.Cmds.Cast<Cmd>().TakeWhile( c => c is AssumeCmd && QKeyValue.FindBoolAttribute(((AssumeCmd)c).Attributes, "partition")); Expr pred = null; if (parts.Count() > 0) { pred = parts.Select(a => ((AssumeCmd)a).Expr).Aggregate(Expr.And); block.Cmds = new List<Cmd>(block.Cmds.Cast<Cmd>().Skip(parts.Count()).ToArray()); } else { continue; } Block realDest = block; if (block.Cmds.Count == 0) { var gc = block.TransferCmd as GotoCmd; if (gc != null && gc.labelTargets.Count == 1) realDest = gc.labelTargets[0]; } partInfo[block] = new PartInfo(pred, realDest); } return partInfo; }
private bool IsPartElements(XmlDictionaryReader reader, PartInfo[] parts) { foreach (PartInfo part in parts) if (IsPartElement(reader, part)) return true; return false; }
/// <summary> /// Initializes the parts and loads all parts to state. /// </summary> public void Initialize() { using (LogGroup logGroup = LogGroup.StartDebug("Initializing the web parts.")) { if (StateAccess.IsInitialized && !PartState.IsInitialized) { PartInfo[] parts = new PartInfo[]{}; bool pageIsAccessible = Page != null; // Only scan for parts if the page component is accessible (otherwise they can't be loaded through LoadControl) // and when the parts have NOT yet been mapped if (pageIsAccessible && !IsCached) { LogWriter.Debug("Is not cached. Scanning from type attributes."); parts = FindParts(); Saver.SaveInfoToFile(parts); Initialize(parts); } else if(IsCached) { LogWriter.Debug("Is cached. Loading from XML."); parts = LoadParts(); Initialize(parts); } } else LogWriter.Debug("State is not initialized. Skipping."); } }
/// <summary> /// Initializes the parts and loads all parts to state. /// </summary> /// <param name="parts">The parts to initialize.</param> public void Initialize(PartInfo[] parts) { PartState.Parts = new PartStateCollection(parts); }
private void SerializeParameters(XmlDictionaryWriter writer, PartInfo[] parts, object[] parameters) { if (parts.Length != parameters.Length) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new ArgumentException(SR.Format(SR.SFxParameterCountMismatch, "parts", parts.Length, "parameters", parameters.Length), "parameters")); for (int i = 0; i < parts.Length; i++) { PartInfo part = parts[i]; SerializeParameter(writer, part, parameters[part.Description.Index]); } }
private void SerializeParameter(XmlDictionaryWriter writer, PartInfo part, object graph) { writer.WriteStartElement(part.DictionaryName, part.DictionaryNamespace); if (graph == null) { writer.WriteStartAttribute(_xsiNilLocalName, _xsiNilNamespace); writer.WriteValue(true); writer.WriteEndAttribute(); } else part.WriteValue(writer, graph); writer.WriteEndElement(); }
private object DeserializeParameter(XmlDictionaryReader reader, PartInfo part) { if (reader.AttributeCount > 0 && reader.MoveToAttribute(_xsiNilLocalName.Value, _xsiNilNamespace.Value) && reader.ReadContentAsBoolean()) { reader.Skip(); return null; } return part.ReadValue(reader); }
private bool IsPartElement(XmlDictionaryReader reader, PartInfo part) { return reader.IsStartElement(part.DictionaryName, part.DictionaryNamespace); }
private object DeserializeParameter(XmlDictionaryReader reader, PartInfo part, bool isRequest) { if (!part.Description.Multiple) { return this.DeserializeParameterPart(reader, part, isRequest); } ArrayList list = new ArrayList(); while (part.Serializer.IsStartObject(reader)) { list.Add(this.DeserializeParameterPart(reader, part, isRequest)); } return list.ToArray(part.Description.Type); }
/// <summary> /// Extracts the part infos from the provided file path. /// </summary> /// <param name="filePath">The full path to the part (.ascx) file.</param> /// <returns></returns> public PartInfo[] ExtractPartInfo(string filePath) { string shortName = Path.GetFileNameWithoutExtension(filePath); string extension = Path.GetExtension(filePath).Trim('.'); string[] actions = ExtractActions(shortName); string typeName = ExtractType(shortName); List<PartInfo> parts = new List<PartInfo>(); string relativeFilePath = filePath.Replace(StateAccess.State.PhysicalApplicationPath, "") .Replace(@"\", "/") .Trim('/'); foreach (string action in actions) { PartInfo info = new PartInfo(); info.Action = action; info.TypeName = typeName; info.PartFilePath = relativeFilePath; BasePart p = (BasePart)ControlLoader.LoadControl(filePath); if (p == null) throw new ArgumentException("Cannot find part file at path: " + filePath); // Ensure that the info properties have been set p.InitializeInfo(); info.MenuTitle = p.MenuTitle; info.MenuCategory = p.MenuCategory; parts.Add(info); } return parts.ToArray(); }
private void DeserializeParameters(XmlDictionaryReader reader, PartInfo[] parts, object[] parameters) { if (parts.Length != parameters.Length) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new ArgumentException(SR.Format(SR.SFxParameterCountMismatch, "parts", parts.Length, "parameters", parameters.Length), "parameters")); int nextPartIndex = 0; while (reader.IsStartElement()) { for (int i = nextPartIndex; i < parts.Length; i++) { PartInfo part = parts[i]; if (IsPartElement(reader, part)) { parameters[part.Description.Index] = DeserializeParameter(reader, parts[i]); nextPartIndex = i + 1; } else parameters[part.Description.Index] = null; } if (reader.IsStartElement()) OperationFormatter.TraceAndSkipElement(reader); } }
public void LoadPartList(XElement xml) { foreach (XElement item in xml.Elements()) { string name = item.Element("Name").Value.Trim(); string description = item.Element("Description").Value.Trim(); string deviceName = item.Element("DeviceName").Value.Trim(); object obj = FAReflection.GetPropertyValue(this, name); if ((obj is FAPart) == false) { throw new Exception(name + " is not FAPart"); } FAPart part = obj as FAPart; part.Description = description; part.Name = name; part.FullName = this.Name + "." + part.Name; part.DeviceName = deviceName; if (EquipmentManager.Instance.DeviceManager.Items.ContainsKey(deviceName)) part.SetDevice(EquipmentManager.Instance.DeviceManager.Items[deviceName]); try { if (item.Element("Parameters") != null) part.LoadParameters(item.Element("Parameters")); if (item.Element("Reference") != null) SetPartReference(part, item.Element("Reference")); PartInfo partInfo = new PartInfo(); partInfo.Part = part; partInfo.PartXMLInfo = item; _partList.Add(partInfo); } catch (Exception e) { throw new Exception("Part Name is " + name + ".\n" + e.Message); } } }
private void SerializeParameters(XmlDictionaryWriter writer, PartInfo[] parts, object[] parameters) { for (int i = 0; i < parts.Length; i++) { PartInfo part = parts[i]; object graph = parameters[part.Description.Index]; this.SerializeParameter(writer, part, graph); } }
/// <summary> /// Loads all the parts found in the parts file. /// </summary> /// <param name="includeDisabled">A value indicating whether or not to include disabled parts.</param> /// <returns>An array of the the parts found.</returns> public PartInfo[] LoadInfoFromFile(bool includeDisabled) { // Logging disabled to boost performance //using (LogGroup logGroup = LogGroup.StartDebug("Loading the parts from the XML file.")) //{ if (Parts == null) { List<PartInfo> validParts = new List<PartInfo>(); PartInfo[] parts = new PartInfo[]{}; using (StreamReader reader = new StreamReader(File.OpenRead(FileNamer.PartsInfoFilePath))) { XmlSerializer serializer = new XmlSerializer(typeof(PartInfo[])); parts = (PartInfo[])serializer.Deserialize(reader); } foreach (PartInfo part in parts) if (part.Enabled || includeDisabled) validParts.Add(part); Parts = validParts.ToArray(); } //} return Parts; }
private static PartInfo[] AddToDictionary(XmlDictionary dictionary, MessagePartDescriptionCollection parts, bool isRpc) { PartInfo[] partInfos = new PartInfo[parts.Count]; for (int i = 0; i < parts.Count; i++) { partInfos[i] = AddToDictionary(dictionary, parts[i], isRpc); } return partInfos; }