OAProperty.cs :  » Development » StyleCop » Microsoft » VisualStudio » Package » Automation » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Development » StyleCop 
StyleCop » Microsoft » VisualStudio » Package » Automation » OAProperty.cs
/***************************************************************************

Copyright (c) Microsoft Corporation. All rights reserved.
This code is licensed under the Visual Studio SDK license terms.
THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.

***************************************************************************/

using System;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Shell;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.Collections;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Reflection;
using IServiceProviderSystem.IServiceProvider;
using Microsoft.VisualStudio.OLE.Interop;
using EnvDTE;

namespace Microsoft.VisualStudio.Package.Automation{
  [CLSCompliant(false), ComVisible(true)]
  public class OAProperty : EnvDTE.Property
  {
    #region fields
    private OAProperties parent;
    private PropertyInfo pi;
    #endregion

    #region ctors

    public OAProperty(OAProperties parent, PropertyInfo pi)
    {
      this.parent = parent;
      this.pi = pi;
    }
    #endregion

    #region EnvDTE.Property
    /// <summary>
    /// Microsoft Internal Use Only.
    /// </summary>
    public object Application
    {
      get { return null; }
    }

    /// <summary>
    /// Gets the Collection containing the Property object supporting this property.
    /// </summary>
    public EnvDTE.Properties Collection
    {
      get
      {
        //todo: EnvDTE.Property.Collection
        return this.parent;
      }
    }

    /// <summary>
    /// Gets the top-level extensibility object.
    /// </summary>
    public EnvDTE.DTE DTE
    {
      get
      {
        return this.parent.DTE;
      }
    }

    /// <summary>
    /// Returns one element of a list. 
    /// </summary>
    /// <param name="index1">The index of the item to display.</param>
    /// <param name="index2">The index of the item to display. Reserved for future use.</param>
    /// <param name="index3">The index of the item to display. Reserved for future use.</param>
    /// <param name="index4">The index of the item to display. Reserved for future use.</param>
    /// <returns>The value of a property</returns>
    public object get_IndexedValue(object index1, object index2, object index3, object index4)
    {
      ParameterInfo[] par = pi.GetIndexParameters();
      int len = Math.Min(par.Length, 4);
      if (len == 0) return this.Value;
      object[] index = new object[len];
      Array.Copy(new object[4] { index1, index2, index3, index4 }, index, len);
      return this.pi.GetValue(this.parent.Target, index);
    }

    /// <summary>
    /// Setter function to set properties values. 
    /// </summary>
    /// <param name="value"></param>
    public void let_Value(object value)
    {
      this.Value = value;
    }

    /// <summary>
    /// Gets the name of the object.
    /// </summary>
    public string Name
    {
      get
      {
        return pi.Name;
      }
    }

    /// <summary>
    /// Gets the number of indices required to access the value.
    /// </summary>
    public short NumIndices
    {
      get { return (short)pi.GetIndexParameters().Length; }
    }

    /// <summary>
    /// Sets or gets the object supporting the Property object.
    /// </summary>
    public object Object
    {
      get
      {
        return this.parent.Target;
      }
      set
      {
      }
    }

    /// <summary>
    /// Microsoft Internal Use Only.
    /// </summary>
    public EnvDTE.Properties Parent
    {
      get { return this.parent; }
    }

    /// <summary>
    /// Sets the value of the property at the specified index.
    /// </summary>
    /// <param name="index1">The index of the item to set.</param>
    /// <param name="index2">Reserved for future use.</param>
    /// <param name="index3">Reserved for future use.</param>
    /// <param name="index4">Reserved for future use.</param>
    /// <param name="value">The value to set.</param>
    public void set_IndexedValue(object index1, object index2, object index3, object index4, object value)
    {
      ParameterInfo[] par = pi.GetIndexParameters();
      int len = Math.Min(par.Length, 4);
      if (len == 0)
      {
        this.Value = value;
      }
      else
      {
        object[] index = new object[len];
        Array.Copy(new object[4] { index1, index2, index3, index4 }, index, len);

        IVsExtensibility3 extensibility = this.parent.Target.Node.ProjectMgr.Site.GetService(typeof(IVsExtensibility)) as IVsExtensibility3;

        if (extensibility == null)
        {
          throw new InvalidOperationException();
        }

        extensibility.EnterAutomationFunction();

        try
        {
          this.pi.SetValue(this.parent.Target, value, index);
        }
        finally
        {
          extensibility.ExitAutomationFunction();
        }
      }

    }

    /// <summary>
    /// Gets or sets the value of the property returned by the Property object.
    /// </summary>
    public object Value
    {
      get { return pi.GetValue(this.parent.Target, null); }
      set
      {
        IVsExtensibility3 extensibility = this.parent.Target.Node.ProjectMgr.Site.GetService(typeof(IVsExtensibility)) as IVsExtensibility3;

        if (extensibility == null)
        {
          throw new InvalidOperationException();
        }

        extensibility.EnterAutomationFunction();

        try
        {
          this.pi.SetValue(this.parent.Target, value, null);
        }
        finally
        {
          extensibility.ExitAutomationFunction();
        }
      }
    }
    #endregion
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.