예제 #1
0
        void FileLoader_GetFileAsTextCompleted(object sender, GetFileAsTextCompletedEventArgs e)
        {
            string configFileXml = e.FileContents;

            if (string.IsNullOrEmpty(configFileXml))
            {
                OnGetConnectionsFailed(new ExceptionEventArgs(new Exception(Resources.Strings.ExceptionConfigurationXmlIsEmpty), e.UserState));
                return;
            }

            try
            {
                List <Connection> connections = null;
                using (MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(configFileXml)))
                {
                    DataContractSerializer serializer = new DataContractSerializer(typeof(List <Connection>));
                    connections = serializer.ReadObject(ms) as List <Connection>;
                }
                AddUserConnectionsToAvailableConnections(connections);
                OnGetConnectionsCompleted(new GetConnectionsCompletedEventArgs()
                {
                    Connections = connections, UserState = e.UserState
                });
            }
            catch (Exception ex)
            {
                OnGetConnectionsFailed(new ExceptionEventArgs(ex, e.UserState));
            }
        }
예제 #2
0
        void FileLoader_FileLoaded(object sender, GetFileAsTextCompletedEventArgs e)
        {
            string configFileXml = e.FileContents;

            if (string.IsNullOrEmpty(configFileXml))
            {
                OnGetConfigurationStoreFailed(new ExceptionEventArgs(new Exception(Resources.Strings.ExceptionConfigurationXmlIsEmpty), e.UserState));
                return;
            }

            try
            {
                ConfigurationStore store = null;
                using (MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(configFileXml)))
                {
                    DataContractSerializer serializer = new DataContractSerializer(typeof(ConfigurationStore));
                    store = serializer.ReadObject(ms) as ConfigurationStore;
                }
                OnGetConfigurationStoreCompleted(new GetConfigurationStoreCompletedEventArgs()
                {
                    ConfigurationStore = store, UserState = e.UserState
                });
            }
            catch (Exception ex)
            {
                OnGetConfigurationStoreFailed(new ExceptionEventArgs(ex, e.UserState));
            }
        }
 protected virtual void OnGetFileAsTextCompleted(GetFileAsTextCompletedEventArgs args)
 {
     if (GetFileAsTextCompleted != null)
     {
         GetFileAsTextCompleted(this, args);
     }
 }
        void FileLoader_GetFileAsTextCompleted(object sender, GetFileAsTextCompletedEventArgs e)
        {
            string configFileXml = e.FileContents;
            if (string.IsNullOrEmpty(configFileXml))
            {
                OnGetConnectionsFailed(new ExceptionEventArgs(new Exception(Resources.Strings.ExceptionConfigurationXmlIsEmpty), e.UserState));
                return;
            }

            try
            {
                List<Connection> connections = null;
                using (MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(configFileXml)))
                {
                    DataContractSerializer serializer = new DataContractSerializer(typeof(List<Connection>));
                    connections = serializer.ReadObject(ms) as List<Connection>;
                }
                AddUserConnectionsToAvailableConnections(connections);
                OnGetConnectionsCompleted(new GetConnectionsCompletedEventArgs() { Connections = connections, UserState = e.UserState });
            }
            catch (Exception ex)
            {
                OnGetConnectionsFailed(new ExceptionEventArgs(ex, e.UserState));
            }
        }
 void FileLoader_FileLoaded(object sender, GetFileAsTextCompletedEventArgs e)
 {
     object[] userState = (e.UserState as object[]);
     if (userState == null || userState.Length < 2)
         return;
     
     EventHandler<ExceptionEventArgs> onFailed = userState[2] as EventHandler<ExceptionEventArgs>;                
     string configFileXml = e.FileContents;
     if (string.IsNullOrEmpty(configFileXml))
     {
         if (onFailed != null)
             onFailed(this, new ExceptionEventArgs(new Exception(Strings.ExceptionConfigurationXmlIsEmpty), e.UserState));
         return;
     }
     EventHandler<GetConfigurationCompletedEventArgs> onCompleted = userState[1] as EventHandler<GetConfigurationCompletedEventArgs>;
     LoadConfigurationFromXmlString(configFileXml, userState[0], onCompleted, onFailed);
 }
        void FileLoader_FileLoaded(object sender, GetFileAsTextCompletedEventArgs e)
        {
            object[] userState = (e.UserState as object[]);
            if (userState == null || userState.Length < 2)
            {
                return;
            }

            EventHandler <ExceptionEventArgs> onFailed = userState[2] as EventHandler <ExceptionEventArgs>;
            string configFileXml = e.FileContents;

            if (string.IsNullOrEmpty(configFileXml))
            {
                if (onFailed != null)
                {
                    onFailed(this, new ExceptionEventArgs(new Exception(Strings.ExceptionConfigurationXmlIsEmpty), e.UserState));
                }
                return;
            }
            EventHandler <GetConfigurationCompletedEventArgs> onCompleted = userState[1] as EventHandler <GetConfigurationCompletedEventArgs>;

            LoadConfigurationFromXmlString(configFileXml, userState[0], onCompleted, onFailed);
        }
 void FileLoader_FileLoaded(object sender, GetFileAsTextCompletedEventArgs e)
 {
     string configFileXml = e.FileContents;            
     if (string.IsNullOrEmpty(configFileXml))
     {
         OnGetConfigurationStoreFailed(new ExceptionEventArgs(new Exception(Resources.Strings.ExceptionConfigurationXmlIsEmpty), e.UserState));
         return;
     }
     
     try
     {
         ConfigurationStore store = null;
         using (MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(configFileXml)))
         {
             DataContractSerializer serializer = new DataContractSerializer(typeof(ConfigurationStore));
             store = serializer.ReadObject(ms) as ConfigurationStore;                    
         }
         OnGetConfigurationStoreCompleted(new GetConfigurationStoreCompletedEventArgs() { ConfigurationStore = store, UserState = e.UserState });
     }
     catch (Exception ex)
     {
         OnGetConfigurationStoreFailed(new ExceptionEventArgs(ex, e.UserState));
     }
 }        
예제 #8
0
 protected virtual void OnGetFileAsTextCompleted(GetFileAsTextCompletedEventArgs args)
 {
     if (GetFileAsTextCompleted != null)
         GetFileAsTextCompleted(this, args);
 }