CiscoIPPhoneMenuType Read4_CiscoIPPhoneMenuType(bool isNullable, bool checkType) { System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { if (xsiType == null || ((object) ((System.Xml.XmlQualifiedName)xsiType).Name == (object)id73_CiscoIPPhoneMenuType && (object) ((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)id2_Item)) { } else throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; CiscoIPPhoneMenuType o; o = new CiscoIPPhoneMenuType(); CiscoIPPhoneMenuItemType[] a_2 = null; int ca_2 = 0; CiscoIPPhoneSoftKeyType[] a_3 = null; int ca_3 = 0; bool[] paramsRead = new bool[4]; while (Reader.MoveToNextAttribute()) { if (!IsXmlnsAttribute(Reader.Name)) { UnknownNode((object)o); } } Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); o.@MenuItem = (CiscoIPPhoneMenuItemType[])ShrinkArray(a_2, ca_2, typeof(CiscoIPPhoneMenuItemType), true); o.@SoftKeyItem = (CiscoIPPhoneSoftKeyType[])ShrinkArray(a_3, ca_3, typeof(CiscoIPPhoneSoftKeyType), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations22 = 0; int readerCount22 = ReaderCount; while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[0] && ((object) Reader.LocalName == (object)id43_Title && (object) Reader.NamespaceURI == (object)id2_Item)) { { o.@Title = Reader.ReadElementString(); } paramsRead[0] = true; } else if (!paramsRead[1] && ((object) Reader.LocalName == (object)id44_Prompt && (object) Reader.NamespaceURI == (object)id2_Item)) { { o.@Prompt = Reader.ReadElementString(); } paramsRead[1] = true; } else if (((object) Reader.LocalName == (object)id57_MenuItem && (object) Reader.NamespaceURI == (object)id2_Item)) { a_2 = (CiscoIPPhoneMenuItemType[])EnsureArrayIndex(a_2, ca_2, typeof(CiscoIPPhoneMenuItemType));a_2[ca_2++] = Read2_CiscoIPPhoneMenuItemType(false, true); } else if (((object) Reader.LocalName == (object)id51_SoftKeyItem && (object) Reader.NamespaceURI == (object)id2_Item)) { a_3 = (CiscoIPPhoneSoftKeyType[])EnsureArrayIndex(a_3, ca_3, typeof(CiscoIPPhoneSoftKeyType));a_3[ca_3++] = Read3_CiscoIPPhoneSoftKeyType(false, true); } else { UnknownNode((object)o, @":Title, :Prompt, :MenuItem, :SoftKeyItem"); } } else { UnknownNode((object)o, @":Title, :Prompt, :MenuItem, :SoftKeyItem"); } Reader.MoveToContent(); CheckReaderCount(ref whileIterations22, ref readerCount22); } o.@MenuItem = (CiscoIPPhoneMenuItemType[])ShrinkArray(a_2, ca_2, typeof(CiscoIPPhoneMenuItemType), true); o.@SoftKeyItem = (CiscoIPPhoneSoftKeyType[])ShrinkArray(a_3, ca_3, typeof(CiscoIPPhoneSoftKeyType), true); ReadEndElement(); return o; }
void Write4_CiscoIPPhoneMenuType(string n, string ns, CiscoIPPhoneMenuType o, bool isNullable, bool needType) { if ((object)o == null) { if (isNullable) WriteNullTagLiteral(n, ns); return; } if (!needType) { System.Type t = o.GetType(); if (t == typeof(CiscoIPPhoneMenuType)) { } else { throw CreateUnknownTypeException(o); } } WriteStartElement(n, ns, o, false, null); if (needType) WriteXsiType(@"CiscoIPPhoneMenuType", @""); WriteElementString(@"Title", @"", ((global::System.String)o.@Title)); WriteElementString(@"Prompt", @"", ((global::System.String)o.@Prompt)); { CiscoIPPhoneMenuItemType[] a = (CiscoIPPhoneMenuItemType[])o.@MenuItem; if (a != null) { for (int ia = 0; ia < a.Length; ia++) { Write2_CiscoIPPhoneMenuItemType(@"MenuItem", @"", ((CiscoIPPhoneMenuItemType)a[ia]), false, false); } } } { CiscoIPPhoneSoftKeyType[] a = (CiscoIPPhoneSoftKeyType[])o.@SoftKeyItem; if (a != null) { for (int ia = 0; ia < a.Length; ia++) { Write3_CiscoIPPhoneSoftKeyType(@"SoftKeyItem", @"", ((CiscoIPPhoneSoftKeyType)a[ia]), false, false); } } } WriteEndElement(o); }
public void GetDirectoriesForCiscoIPPhone() { CiscoIPPhoneMenuType menu = new CiscoIPPhoneMenuType(); menu.Prompt = "Sélectionner un répertoire"; menu.Title = "Répertoires"; try { List <CiscoIPPhoneMenuItemType> menus = new List <CiscoIPPhoneMenuItemType>(); foreach (DirectoryType dt in Global.directoryConfiguration) { CiscoIPPhoneMenuItemType menuitem = null; bool isIPPhoneCompliant = false; if (dt.Item is SqlDatasourceType) { SqlDatasourceType sdt = dt.Item as SqlDatasourceType; if (sdt.ipphonefilter != null) { isIPPhoneCompliant = true; } } else if (dt.Item is LdapDatasourceType) { LdapDatasourceType ldt = dt.Item as LdapDatasourceType; if (ldt.ipphonefilter != null) { isIPPhoneCompliant = true; } } else if (dt.Item is CiscoDatasourceType) { CiscoDatasourceType cdt = dt.Item as CiscoDatasourceType; if (cdt.ipphonefilter != null) { isIPPhoneCompliant = true; } } if (isIPPhoneCompliant) { menuitem = new CiscoIPPhoneMenuItemType(); menuitem.Name = dt.name; menuitem.URL = this.Context.Request.Url.AbsoluteUri.Substring(0, this.Context.Request.Url.AbsoluteUri.LastIndexOf("/") + 1) + "SearchForCiscoIPPhone?directory=" + System.Web.HttpUtility.UrlEncode(dt.name); menus.Add(menuitem); } } if (menus.Count > 0) { menu.MenuItem = menus.ToArray(); } else { this.Context.Response.Redirect(this.Context.Request.Url.AbsoluteUri.Substring(0, this.Context.Request.Url.AbsoluteUri.LastIndexOf("/") + 1) + "Error?error=" + System.Web.HttpUtility.UrlEncode("No ipphone directories finded"), false); //return menu; } //return menu; CiscoIPPhoneMenuTypeSerializer xml = new CiscoIPPhoneMenuTypeSerializer(); System.Xml.XmlWriterSettings settings = new System.Xml.XmlWriterSettings();; settings.Encoding = System.Text.Encoding.UTF8; System.IO.MemoryStream ms = new System.IO.MemoryStream(); System.Xml.XmlWriter xw = System.Xml.XmlWriter.Create(ms, settings); System.Xml.Serialization.XmlSerializerNamespaces xmlnsEmpty = new System.Xml.Serialization.XmlSerializerNamespaces(); xmlnsEmpty.Add("", ""); xml.Serialize(xw, menu, xmlnsEmpty); ms.Position = 0; this.Context.Response.ContentType = "text/xml"; this.Context.Response.ContentEncoding = System.Text.Encoding.UTF8; this.Context.Response.Write(GetStringFromStream(ms)); //xw.Flush(); //xw.Close(); } catch (Exception e) { log.Error("Unable get directories: " + e.Message); this.Context.Response.Redirect(this.Context.Request.Url.AbsoluteUri.Substring(0, this.Context.Request.Url.AbsoluteUri.LastIndexOf("/") + 1) + "Error?error=" + System.Web.HttpUtility.UrlEncode(e.Message), false); //return menu; } }