Beispiel #1
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="obj"></param>
 /// <returns></returns>
 public static ICommandTarget AsCommandTarget(IAdaptable obj)
 {
     if (obj == null)
         return null;
     else
         return (ICommandTarget)obj.GetAdapter(typeof(ICommandTarget));
 }
Beispiel #2
0
 public bool CanOperateOn(IAdaptable parent)
 {
     // return parent.Is<DomNodeAdapters.Game>()
     //     || parent.Is<DomNodeAdapters.PlacementsFolder>();
     return false;
 }
Beispiel #3
0
 //上のGeneric版
 T IAdapterManager.GetAdapter <T>(IAdaptable obj)
 {
     return((T)GetAdapter(obj, typeof(T)));
 }
Beispiel #4
0
        public static void SelectNameForReferencedDocuments(IAdaptable gameNode)
        {
            var game = gameNode.As<Game.GameExtensions>();
            if (game == null) return;

            var placementsFolder = game.PlacementsFolder;
            if (placementsFolder != null)
                foreach (var cellRef in placementsFolder.Cells)
                    cellRef.SelectNameIfNecessary();
        }
Beispiel #5
0
        public static void ResolveOnLoad(IAdaptable gameNode)
        {
            var game = gameNode.As<Game.GameExtensions>();
            if (game == null) return;

            var placementsFolder = game.PlacementsFolder;
            if (placementsFolder != null)
            {
                foreach (var cell in placementsFolder.Cells)
                {
                    cell.Resolve();
                }
            }
        }
 /// <summary>
 /// Adapts a <see cref="ProjectItem"/> to a <see cref="EnvDTE.ProjectItem"/>.
 /// </summary>
 /// <returns>The <see cref="EnvDTE.ProjectItem"/> or <see langword="null"/> if conversion is not possible.</returns>
 public static EnvDTE.ProjectItem AsDteProjectItem(this IAdaptable <ProjectItem> adaptable)
 {
     return(adaptable.AsItemNode().As <EnvDTE.ProjectItem>());
 }
        IProject getProject()
        {
            IAdaptable adaptable = getElement();

            return(adaptable == null ? null : (IProject)adaptable.getAdapter(typeof(IProject)));
        }
Beispiel #8
0
 /// <summary>
 /// Adapts a <see cref="IProjectNode"/> to a <see cref="Microsoft.Build.Evaluation.Project"/>.
 /// </summary>
 /// <returns>The <see cref="Microsoft.Build.Evaluation.Project"/> or <see langword="null"/> if conversion is not possible.</returns>
 public static Microsoft.Build.Evaluation.Project AsMsBuildProject(this IAdaptable <IProjectNode> adaptable)
 {
     return(adaptable.As <Microsoft.Build.Evaluation.Project>());
 }
Beispiel #9
0
 /// <summary>
 /// Returns a value indicating if the given reference can be converted to one of
 /// the desired type</summary>
 /// <typeparam name="T">Adapter type, must be ref type</typeparam>
 /// <param name="adaptable">Adaptable object</param>
 /// <returns>True iff the given object can be converted</returns>
 public static bool Is <T>(this IAdaptable adaptable)
     where T : class
 {
     return(As <T>(adaptable) != null);
 }
Beispiel #10
0
 /// <summary>
 /// Adapts a <see cref="ISolutionNode"/> to a DTE <see cref="EnvDTE.Solution"/>.
 /// </summary>
 /// <returns>The DTE <see cref="Solution"/> or <see langword="null"/> if conversion is not possible.</returns>
 public static EnvDTE.Solution AsSolutionNode(this IAdaptable <ISolutionNode> adaptable)
 {
     return(adaptable.As <EnvDTE.Solution>());
 }
Beispiel #11
0
 /// <summary>
 /// Adapts a <see cref="ISolutionNode"/> to an <see cref="IVsSolution"/>.
 /// </summary>
 /// <returns>The <see cref="IVsSolution"/> or <see langword="null"/> if conversion is not possible.</returns>
 public static IVsSolution AsVsSolution(this IAdaptable <ISolutionNode> adaptable)
 {
     return(adaptable.As <IVsSolution>());
 }
Beispiel #12
0
 /// <summary>
 /// Adapts a <see cref="IReferencesNode"/> to a VsLang <see cref="References"/>.
 /// </summary>
 /// <returns>The <see cref="References"/> or <see langword="null"/> if conversion is not possible.</returns>
 public static References AsReferences(this IAdaptable <IReferencesNode> adaptable)
 {
     return(adaptable.As <References>());
 }
Beispiel #13
0
 /// <summary>
 /// Adapts a <see cref="IReferenceNode"/> to a VsLang <see cref="Reference"/>.
 /// </summary>
 /// <returns>The <see cref="Reference"/> or <see langword="null"/> if conversion is not possible.</returns>
 public static Reference AsReference(this IAdaptable <IReferenceNode> adaptable)
 {
     return(adaptable.As <Reference>());
 }
Beispiel #14
0
 /// <summary>
 /// Adapts a <see cref="IItemNode"/> to a <see cref="Microsoft.Build.Evaluation.ProjectItem"/>.
 /// </summary>
 /// <returns>The <see cref="Microsoft.Build.Evaluation.ProjectItem"/> or <see langword="null"/> if conversion is not possible.</returns>
 public static Microsoft.Build.Evaluation.ProjectItem AsMsBuildItem(this IAdaptable <IItemNode> adaptable)
 {
     return(adaptable.As <Microsoft.Build.Evaluation.ProjectItem>());
 }
        public void ApplyParam(IAdaptable destination, ITerminalSettings terminal) {
            _initializing = true;
            Debug.Assert(destination != null);
            Debug.Assert(terminal != null);
            this.TerminalSettings = terminal.Clone();

            ITCPParameter tcp_destination = (ITCPParameter)destination.GetAdapter(typeof(ITCPParameter));
            ISSHLoginParameter ssh_destination = (ISSHLoginParameter)destination.GetAdapter(typeof(ISSHLoginParameter));
            bool is_telnet = ssh_destination == null;

            _methodBox.SelectedItem =
                is_telnet ? ConnectionMethod.Telnet :
                    ssh_destination.Method == SSHProtocol.SSH1 ? ConnectionMethod.SSH1 : ConnectionMethod.SSH2; // select ListItem<T> by T
            _portBox.SelectedIndex = _portBox.FindStringExact(PortDescription(tcp_destination.Port));
            if (ssh_destination != null) {
                _userNameBox.SelectedIndex = _userNameBox.FindStringExact(ssh_destination.Account);
                _passphraseBox.Text = ssh_destination.PasswordOrPassphrase;

                if (ssh_destination.AuthenticationType == AuthenticationType.PublicKey)
                    _privateKeyFile.Text = ssh_destination.IdentityFileName;
                else
                    _privateKeyFile.Text = "";
                _authOptions.SelectedItem = ToAuthType(ssh_destination.AuthenticationType); // select EnumListItem<T> by T
            }

            IAutoExecMacroParameter autoExecParams = destination.GetAdapter(typeof(IAutoExecMacroParameter)) as IAutoExecMacroParameter;
            if (autoExecParams != null && TelnetSSHPlugin.Instance.MacroEngine != null) {
                _autoExecMacroPathBox.Text = (autoExecParams.AutoExecMacroPath != null) ? autoExecParams.AutoExecMacroPath : String.Empty;
            }
            else {
                _autoExecMacroPathLabel.Enabled = false;
                _autoExecMacroPathBox.Enabled = false;
                _selectAutoExecMacroButton.Enabled = false;
            }

            if (is_telnet) {
                ITelnetParameter telnetParams = (ITelnetParameter)destination.GetAdapter(typeof(ITelnetParameter));
                _telnetNewLine.Checked = (telnetParams != null) ? telnetParams.TelnetNewLine : true;
            }
            else {
                _telnetNewLine.Checked = true;
            }

            _encodingBox.SelectedItem = terminal.Encoding;              // select EnumListItem<T> by T
            _newLineBox.SelectedItem = terminal.TransmitNL;             // select EnumListItem<T> by T
            _localEchoBox.SelectedItem = terminal.LocalEcho;            // select ListItem<T> by T
            _terminalTypeBox.SelectedItem = terminal.TerminalType;      // select EnumListItem<T> by T
            _initializing = false;

            EnableValidControls();
        }
Beispiel #16
0
 //一つしかインスタンスがないのをいいことに唯一のを返す
 public IAdaptable GetAdapter(IAdaptable obj)
 {
     return(_coreServices);
 }
Beispiel #17
0
 public IAdaptable GetSource(IAdaptable obj) {
     return _world;
 }
Beispiel #18
0
 public IAdaptable GetSource(IAdaptable obj)
 {
     return(_world);
 }
Beispiel #19
0
 /// <summary>
 /// <ja>
 /// 含まれる複数のメニュー項目とメニュー項目の直前に区切り記号(セパレータ)を表示するか否か
 /// を指定してメニューグループを作成します。
 /// </ja>
 /// <en>
 /// The menu group is made specifying whether to display the separator just before two or more included menu item and menu item. 
 /// </en>
 /// </summary>
 /// <param name="childMenus"><ja>含めたいメニュー項目の配列です。</ja><en>Array of menu item that wants to be included</en></param>
 /// <param name="showSeparator"><ja>セパレータを表示するか否かの指定です。trueのとき表示、falseのとき非表示です。</ja>
 /// <en>It is specification whether to display the separator. It displays at true, and non-display at false. </en></param>
 public PoderosaMenuGroupImpl(IPoderosaMenu[] childMenus, bool showSeparator) {
     _childMenus = childMenus;
     _isVolatile = false;
     _showSeparator = showSeparator;
     _designationTarget = null;
     _positionType = PositionType.First;
 }
Beispiel #20
0
 public PD(int index, IAdaptable target, PositionType pos)
     : base(index)
 {
     _target   = target;
     _position = pos;
 }
 /// <summary>
 /// Adapts a <see cref="ProjectItem"/> to an <see cref="IItemNode"/>.
 /// </summary>
 /// <returns>The <see cref="IItemNode"/> or <see langword="null"/> if conversion is not possible.</returns>
 public static IItemNode AsItemNode(this IAdaptable <ProjectItem> adaptable)
 {
     return(adaptable.As <IItemNode>());
 }
Beispiel #22
0
 public new void SetReference(AttributeInfo attributeInfo, IAdaptable value)
 {
     base.SetReference(attributeInfo, value);
 }
Beispiel #23
0
 public Entry(int i, IAdaptable c)
 {
     index       = i;
     content     = c;
     designation = (IPositionDesignation)c.GetAdapter(typeof(IPositionDesignation));
 }
Beispiel #24
0
 public new void SetChild(ChildInfo childInfo, IAdaptable value)
 {
     base.SetChild(childInfo, value);
 }
Beispiel #25
0
        public static void SaveReferencedDocuments(IAdaptable gameNode, ISchemaLoader schemaLoader)
        {
            var game = gameNode.As<Game.GameExtensions>();
            if (game == null) return;

            var placementsFolder = game.PlacementsFolder;
            if (placementsFolder != null)
            {
                foreach (var cellRef in placementsFolder.Cells)
                {
                    var doc = cellRef.Target;
                    if (doc == null) continue;
                    doc.Save(cellRef.Uri, schemaLoader);
                }
            }
        }
Beispiel #26
0
        /// <summary>
        /// Sets the attribute of the adapted DomNode to reference a new DomNode</summary>
        /// <param name="attributeInfo">Metadata to indicate which attribute to set</param>
        /// <param name="value">Any IAdaptable, such as DomNodeAdapter, DomNode, or IAdapter</param>
        protected void SetReference(AttributeInfo attributeInfo, IAdaptable value)
        {
            DomNode refNode = value.As <DomNode>();

            DomNode.SetAttribute(attributeInfo, refNode);
        }
Beispiel #27
0
        public static void Unresolve(IAdaptable gameNode)
        {
            var game = gameNode.As<Game.GameExtensions>();
            if (game == null) return;

            var placementsFolder = game.PlacementsFolder;
            if (placementsFolder != null)
            {
                foreach (var cell in placementsFolder.Cells)
                {
                    cell.Unresolve();
                }
            }

                // Detach all children
                // This will cause the native adapters to destroy the associated native objects.
            foreach (var c in game.DomNode.Children)
                c.RemoveFromParent();
        }
Beispiel #28
0
        /// <summary>
        /// Sets the child of our adapted DomNode to a new DomNode</summary>
        /// <param name="childInfo">Metadata to indicate the child</param>
        /// <param name="value">Any IAdaptable, such as DomNodeAdapter, DomNode, or IAdapter</param>
        protected void SetChild(ChildInfo childInfo, IAdaptable value)
        {
            DomNode child = value.As <DomNode>();

            DomNode.SetChild(childInfo, child);
        }
Beispiel #29
0
        private IAdaptable ChallengeUsingAdapterFactory(IDualDirectionalAdapterFactory factory, IAdaptable obj, Type adapter)
        {
            Type dest = factory.SourceType == obj.GetType()? factory.AdapterType : factory.SourceType; //変換先クラス

            if (adapter.IsAssignableFrom(dest))                                                        //これならビンゴといっていい。現在はこのケースしかないはず
            {
                IAdaptable t = factory.SourceType == obj.GetType()? factory.GetAdapter(obj) : factory.GetSource(obj);
                Debug.Assert(adapter.IsInstanceOfType(t));
                return(t);
            }

            //複雑なケース。
            //変換後のオブジェクトのGetAdapterを読んでみる(再帰呼び出し対策必要)、
            //2ステップ以上のFactoryを使用する、などが必要。
            //TODO 現在未サポート
            return(null);
        }
 /// <summary>
 /// Adapts a <see cref="ProjectItem"/> to an <see cref="VSProjectItem"/>.
 /// </summary>
 /// <returns>The <see cref="VSProjectItem"/> or <see langword="null"/> if conversion is not possible.</returns>
 public static VSProjectItem AsVsLangItem(this IAdaptable <ProjectItem> adaptable)
 {
     return(adaptable.AsItemNode().As <VSProjectItem>());
 }
Beispiel #31
0
 public void Execute(IAdaptable parent)
 {
 }
 /// <summary>
 /// Adapts a <see cref="Project"/> to an <see cref="IProjectNode"/>.
 /// </summary>
 /// <returns>The <see cref="IProjectNode"/> or <see langword="null"/> if conversion is not possible.</returns>
 public static IProjectNode AsProjectNode(this IAdaptable <Project> adaptable)
 {
     return(adaptable.As <IProjectNode>());
 }
Beispiel #33
0
 //一つしかインスタンスがないのをいいことに唯一のを返す
 public IAdaptable GetAdapter(IAdaptable obj) {
     return _coreServices;
 }
 /// <summary>
 /// Adapts a <see cref="Project"/> to a DTE <see cref="EnvDTE.Project"/>.
 /// </summary>
 /// <returns>The <see cref="Project"/> or <see langword="null"/> if conversion is not possible.</returns>
 public static EnvDTE.Project AsDteProject(this IAdaptable <Project> adaptable)
 {
     return(adaptable.AsProjectNode().As <EnvDTE.Project>());
 }
Beispiel #35
0
 //内部ではITCPParameterかICygwinParameterのどっちかしか呼ばれないはず
 public static void FireConnectionSucceeded(IAdaptable param)
 {
     ITerminalParameter t = (ITerminalParameter)param.GetAdapter(typeof(ITerminalParameter));
     Debug.Assert(t != null);
     if (ProtocolsPlugin.Instance != null) {
         foreach (IConnectionResultEventHandler h in ProtocolsPlugin.Instance.ConnectionResultEventHandler.GetExtensions()) {
             h.OnSucceeded(t);
         }
     }
 }
 /// <summary>
 /// Adapts a <see cref="Project"/> to a <see cref="IVsProject"/>.
 /// </summary>
 /// <returns>The <see cref="IVsProject"/> or <see langword="null"/> if conversion is not possible.</returns>
 public static IVsProject AsVsProject(this IAdaptable <Project> adaptable)
 {
     return(adaptable.AsProjectNode().As <IVsProject>());
 }
Beispiel #37
0
 public PD(int index, IAdaptable target, PositionType pos)
     : base(index) {
     _target = target;
     _position = pos;
 }
 /// <summary>
 /// Adapts a <see cref="Project"/> to a <see cref="VSProject"/>.
 /// </summary>
 /// <returns>The <see cref="VSProject"/> or <see langword="null"/> if conversion is not possible.</returns>
 public static VSProject AsVsLangProject(this IAdaptable <Project> adaptable)
 {
     return(adaptable.AsProjectNode().As <VSProject>());
 }
Beispiel #39
0
 //ポジションセット
 /// <summary>
 /// <ja>
 /// メニューの位置を設定します。
 /// </ja>
 /// <en>
 /// Set The position of the menu.
 /// </en>
 /// </summary>
 /// <param name="type">
 /// <ja>メニューの場所を指定します。</ja>
 /// <en>Specifies the place of the menu.</en>
 /// </param>
 /// <param name="target">
 /// <ja>どのメニューに対する位置なのかを指定します。<see cref="IPoderosaMenuGroup">IPoderosaMenuGroup</see>でなければなりません。</ja>
 /// <en>To which menu position it is is specified. It should be <see cref="IPoderosaMenuGroup">IPoderosaMenuGroup</see>. </en>
 /// </param>
 /// <returns><ja>このオブジェクト自身が戻ります。</ja><en>This object returns. </en></returns>
 /// <remarks>
 /// <ja>
 /// デフォルトでは、メニュー位置は、「先頭(PositionType.First)」に設定されます。詳細は、<seealso cref="IPositionDesignation">IPositionDesignation</seealso>を参照してください。
 /// </ja>
 /// <en>
 /// In default, the menu position is set to the "head(PositionType.First)". 
 /// Refer to <seealso cref="IPositionDesignation">IPositionDesignation</seealso> for more information.
 /// </en>
 /// </remarks>
 public PoderosaMenuGroupImpl SetPosition(PositionType type, IAdaptable target) {
     _positionType = type;
     _designationTarget = target;
     return this;
 }
Beispiel #40
0
 public T As <T>(IAdaptable adapter) where T : new()
 {
     return(adapter.Adapt <string, T>(_importJson));
 }